0

I have not been able to find an answer to how I configure the BannerPixmap for QWizard using a stylesheet or Qt Designer. Can somebody help me out here?

4

2 回答 2

0

您可以在向导或向导页面上设置 Pixmap 属性;例如这个:

    self.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(":/plugins/eaf/eaf3.jpg"))

(其中像素图是一些 Qt 资源)

该方法的第一个参数是向导角色。正如上面的评论所指出的,使用的角色取决于向导风格:

  • WatermarkPixmap(由 ClassicStyle 和 ModernStyle 使用)
  • BannerPixmap(由 ModernStyle 使用)
  • LogoPixmap(由 ClassicStyle 和 ModernStyle 使用)
  • BackgroundPixmap(由 MacStyle 使用)

您可以明确设置向导样式,使用:

setWizardStyle ( WizardStyle style )

[1] https://qt-project.org/doc/qt-4.8/qwizard.html#wizard-look-and-feel

于 2013-10-18T08:19:19.680 回答
0

您可以在查看 QWizard 源代码的向导中自定义按钮以获取对象名称。

每个按钮都有自己的对象名称。 https://code.woboq.org/qt5/qtbase/src/widgets/dialogs/qwizard.cpp.html#_ZL22object_name_for_buttonN7QWizard12WizardButtonE

static QString object_name_for_button(QWizard::WizardButton which)
{
    switch (which) {
    case QWizard::CommitButton:
        return QLatin1String("qt_wizard_") + QLatin1String("commit");
    case QWizard::FinishButton:
        return QLatin1String("qt_wizard_") + QLatin1String("finish");
    case QWizard::CancelButton:
        return QLatin1String("qt_wizard_") + QLatin1String("cancel");
    case QWizard::BackButton:
    case QWizard::NextButton:
    case QWizard::HelpButton:
    case QWizard::CustomButton1:
    case QWizard::CustomButton2:
    case QWizard::CustomButton3:
        // Make navigation buttons detectable as passive interactor in designer
        return QLatin1String("__qt__passive_wizardbutton") + QString::number(which);
    case QWizard::Stretch:
    case QWizard::NoButton:
    //case QWizard::NStandardButtons:
    //case QWizard::NButtons:
        ;
    }
    Q_UNREACHABLE();
    return QString();
}

在样式表中:

/*Next button in the wizard */
QPushButton#__qt__passive_wizardbutton1
{
    background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(35, 200, 183, 100%), stop:1 rgba(35, 167, 212, 100%));
    color: white;
    font: bold;
}

QPushButton#qt_wizard_finish
{
    background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(35, 200, 183, 100%), stop:1 rgba(35, 167, 212, 100%));
    color: white;
    font: bold;
}

QPushButton#qt_wizard_commit
{
    background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(35, 200, 183, 100%), stop:1 rgba(35, 167, 212, 100%));
    color: white;
    font: bold;
}
于 2019-06-04T09:07:05.440 回答