You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PySide6向导页首个按钮呈蓝色的原因排查

为何QWizard中的首个按钮会呈现蓝色?

说明:我承认这可能是重复问题,但个人认为它被标记为错误问题的重复项,更合适的参考问题是关于PyQt5程序中首个按钮变蓝的相关问题。

import sys
from PySide6.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QWizard, QWizardPage

class ThreeButtonsPage(QWizardPage):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        button1 = QPushButton('Button 1', self)
        button2 = QPushButton('Button 2', self)
        button3 = QPushButton('Button 3', self)

        hbox = QHBoxLayout()
        hbox.addWidget(button1)
        hbox.addWidget(button2)
        hbox.addWidget(button3)
        self.setLayout(hbox)

class MyWizard(QWizard):
    def __init__(self):
        super().__init__()
        first_page = ThreeButtonsPage()
        self.addPage(first_page)
        self.setWindowTitle('Wizard Example')

if __name__ == '__main__':
    app = QApplication(sys.argv)
    wizard = MyWizard()
    wizard.show()
    sys.exit(app.exec())

问题详情

为何首个按钮呈蓝色?我提供的代码逻辑清晰,仅首个按钮显示为蓝色。我已排查所有按钮的样式,确认这并非样式问题;且将相同布局用于普通窗口时无此问题,因此该问题似乎是QWizard特有的。

对话框界面

内容的提问来源于stack exchange,提问作者Keeely

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 05:42:44