如何在QWizard的副标题中创建链接?

时间:2022-01-07 07:30:15

I am constructing a little wizard following Qt's classwizard example.

我正在按照Qt的classwizard示例构建一个小向导。

Now I set the subTitle of my QWizard instance to some html text that includes a link. I know about QLabel.setOpenExternalLinks(True) but how do I achieve the same effect with a QWizard's subTitle?

现在我将QWizard实例的副标题设置为包含链接的html文本。我知道QLabel.setOpenExternalLinks(True),但是如何用QWizard的副标题达到同样的效果呢?

I looked at QWizardOptions but there is nothing there.

我查看了QWizardOptions,但那里什么都没有。

Please take a look at the following image:

请看下图:

如何在QWizard的副标题中创建链接?

I want to make www.plugincafe.com open in the default browser.

我想让www.plugincafe.com在默认浏览器中打开。

Thanks for reading.

感谢你的阅读。

EDIT: I am already calling self.setSubTitleFormat(1) where self is the QWizard instance and 1 is the enum value for Qt::RichText because I don't know how to get the proper enum constant in PyQt.

编辑:我已经调用了self。setsubtitleformat (1), self是QWizard实例,1是Qt: RichText的enum值,因为我不知道如何在PyQt中获得适当的enum常量。

I tried all possible 4 enum values but other than text styling or no it didn't change anything.

我尝试了所有可能的4 enum值,但除了文本样式化或否,它没有改变任何东西。

The string value with the embedded HTML is 'Obtain a unique ID from <a href="http://www.plugincafe.com">www.plugincafe.com</a> or use <font color="maroon">%s</font> for testing purposes.' % PLUGIN_ID_TESTING

嵌入HTML的字符串值是“从www.plugincafe.com或使用%s用于测试目的”。' % PLUGIN_ID_TESTING

1 个解决方案

#1


0  

QWizard (and QWizardPage) only expose mimimal control over the QLabel used as subtitle, but you can just iterate through all child QLabels in your QWizard and call setOpenExternalLinks(True):

QWizard(和QWizardPage)只公开作为字幕的QLabel的mimimimal控件,但是您可以遍历QWizard中的所有子QLabel,并调用setOpenExternalLinks(True):

for label in wizard.findChildren(QLabel):
    label.setOpenExternalLinks(True)

If you don't want to set it on all labels, then you need to check if you found the correct one.

如果您不想在所有标签上设置它,那么您需要检查是否找到了正确的标签。

#1


0  

QWizard (and QWizardPage) only expose mimimal control over the QLabel used as subtitle, but you can just iterate through all child QLabels in your QWizard and call setOpenExternalLinks(True):

QWizard(和QWizardPage)只公开作为字幕的QLabel的mimimimal控件,但是您可以遍历QWizard中的所有子QLabel,并调用setOpenExternalLinks(True):

for label in wizard.findChildren(QLabel):
    label.setOpenExternalLinks(True)

If you don't want to set it on all labels, then you need to check if you found the correct one.

如果您不想在所有标签上设置它,那么您需要检查是否找到了正确的标签。