0

I want to use add an Logo to the QWizardPage, however nothing is displayed. I'm using PySide6.

from PySide6.QtCore import Qt
from PySide6.QtWidgets import (QVBoxLayout, QApplication, QWizardPage, QWizard)
from PySide6.QtGui import (QIcon, QPixmap, QImage)

class Page1(QWizardPage):

    def __init__(self, img, parent=None):
        super().__init__(parent)

        self.setTitle('General Properties')
        self.setSubTitle('Enter general properties for this project.')

        # Just for testing, include the same image - this is displayed!
        layout = QVBoxLayout()
        graphics = QLabel(self)
        graphics.setPixmap(QPixmap(img))
        layout.addWidget(graphics)
        self.setLayout(layout)


class ProjectWizard(QWizard):
    def __init__(self, parent=None):
        super().__init__(parent)
        img = './Icon_256.png'

        self.addPage(Page1(img, self))
        self.setWindowTitle("New Project")

        # setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap)
        self.setPixmap(QWizard.LogoPixmap, QPixmap.fromImage(QImage(img)))

The path to the image is valid and accessible (I've included the image in the dialog as well), however, no Image is displayed. Also a change of the which parameter of setPixmap(which, pixmap) does not help. I also did not find anything helpful in the documentation of the QWizardPage documentation page.

Screenshot

Thank you in advance!

agentsmith
  • 1,226
  • 1
  • 14
  • 27
  • Are you sure that the path you're using is correct as a relative one? What is the output of `print(QImage(img).isNull())`? Also note that creating a QImage to get it as a QPixmap is completely pointless, just do `QPixmap(img)`. – musicamante May 04 '23 at 18:10
  • It returns False, as expected. Considering my example, the file loads just fine, using a QLabel with a QPixmap. However, in conjunction with my QWizardPage it does not seem to work, and to me, it looks like a bug at least in the QWizard Pyside implementation, although I did not find anything about this. Regarding the QImage: Usually I do not use this, and I've tried a few things before posting here. This is just a copy-paste relict I forgot, but thank you for that hint. – agentsmith May 05 '23 at 06:48
  • Can you try again using different values for [`setWizardStyle()`](https://doc.qt.io/qt-6/qwizard.html#wizardStyle-prop) values? Also, after setting the pixmap, is the result of `self.pixmap(QWizard.LogoPixmap).isNull()` the same? – musicamante May 09 '23 at 02:40

0 Answers0