

実行環境

  * Windows 10 64bit
  * Python 3.10.2
  * PySide6 6.3.2

Qt Designer にて1つ目の画像のようにQTabWidgetを置き，各タブにラベルを配置しました．  
全ラベルにダイナミックプロパティ"class=big-label"を追加し，以下のスタイルシートにて文字の拡大を試みました．

[code]

    QLabel[class="big-label"] {
        font: 700 30pt;
    }
    
[/code]

DesignerおよびDesignerのプレビュー上では問題なくスタイルが適用されているのですが，いざ以下のプログラムを実行してみると2つ目の画像のように最初の"Tab
1"だけスタイルが適用されません．(`import`している`ui_generated_main_window`の全文は最後に記載しています)

[code]

    import sys
    from PySide6.QtWidgets import QMainWindow, QApplication
    from ui_generated_main_window import Ui_MainWindow
    
    class MainWindow(QMainWindow):
        def __init__(self) -> None:
            super().__init__()
            self.ui = Ui_MainWindow()
            self.ui.setupUi(self)
    
    if __name__ == "__main__":
        app = QApplication([])
        main_window = MainWindow()
        main_window.show()
        sys.exit(app.exec())
    
[/code]

スタイルの適用方法が間違っているのでしょうか．それともPySide6側のバグなのでしょうか．  
解決方法もしくは助言を頂けると幸いです．

[![Qt
Designerでの表示](https://i.stack.imgur.com/J1wNR.png)](https://i.stack.imgur.com/J1wNR.png)  
[![実行時](https://i.stack.imgur.com/q4Ued.png)](https://i.stack.imgur.com/q4Ued.png)

* * *

（参考）

Qt Designer出力の.uiファイルからpyside6-uic.exeにより作成された ui_generated_main_window.py です．

[code]

    # -*- coding: utf-8 -*-
    
    ################################################################################
    ## Form generated from reading UI file 'MainWindow2.ui'
    ##
    ## Created by: Qt User Interface Compiler version 6.3.2
    ##
    ## WARNING! All changes made in this file will be lost when recompiling UI file!
    ################################################################################
    
    from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
        QMetaObject, QObject, QPoint, QRect,
        QSize, QTime, QUrl, Qt)
    from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
        QFont, QFontDatabase, QGradient, QIcon,
        QImage, QKeySequence, QLinearGradient, QPainter,
        QPalette, QPixmap, QRadialGradient, QTransform)
    from PySide6.QtWidgets import (QApplication, QLabel, QMainWindow, QMenuBar,
        QPushButton, QSizePolicy, QStatusBar, QTabWidget,
        QVBoxLayout, QWidget)
    
    class Ui_MainWindow(object):
        def setupUi(self, MainWindow):
            if not MainWindow.objectName():
                MainWindow.setObjectName(u"MainWindow")
            MainWindow.resize(458, 331)
            MainWindow.setStyleSheet(u"QLabel[class=\"big-label\"] {\n"
    "   font: 700 30pt;\n"
    "}")
            self.centralwidget = QWidget(MainWindow)
            self.centralwidget.setObjectName(u"centralwidget")
            self.verticalLayout = QVBoxLayout(self.centralwidget)
            self.verticalLayout.setObjectName(u"verticalLayout")
            self.tabWidget = QTabWidget(self.centralwidget)
            self.tabWidget.setObjectName(u"tabWidget")
            self.tab = QWidget()
            self.tab.setObjectName(u"tab")
            self.button_preview = QPushButton(self.tab)
            self.button_preview.setObjectName(u"button_preview")
            self.button_preview.setGeometry(QRect(288, 580, 151, 24))
            self.label = QLabel(self.tab)
            self.label.setObjectName(u"label")
            self.label.setGeometry(QRect(100, 70, 211, 101))
            self.tabWidget.addTab(self.tab, "")
            self.tab_2 = QWidget()
            self.tab_2.setObjectName(u"tab_2")
            self.label_2 = QLabel(self.tab_2)
            self.label_2.setObjectName(u"label_2")
            self.label_2.setGeometry(QRect(40, 70, 241, 91))
            self.tabWidget.addTab(self.tab_2, "")
            self.tab_3 = QWidget()
            self.tab_3.setObjectName(u"tab_3")
            self.label_3 = QLabel(self.tab_3)
            self.label_3.setObjectName(u"label_3")
            self.label_3.setGeometry(QRect(100, 80, 231, 81))
            self.tabWidget.addTab(self.tab_3, "")
    
            self.verticalLayout.addWidget(self.tabWidget)
    
            MainWindow.setCentralWidget(self.centralwidget)
            self.menubar = QMenuBar(MainWindow)
            self.menubar.setObjectName(u"menubar")
            self.menubar.setGeometry(QRect(0, 0, 458, 22))
            MainWindow.setMenuBar(self.menubar)
            self.statusbar = QStatusBar(MainWindow)
            self.statusbar.setObjectName(u"statusbar")
            MainWindow.setStatusBar(self.statusbar)
    
            self.retranslateUi(MainWindow)
    
            self.tabWidget.setCurrentIndex(2)
    
    
            QMetaObject.connectSlotsByName(MainWindow)
        # setupUi
    
        def retranslateUi(self, MainWindow):
            MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
            self.button_preview.setText(QCoreApplication.translate("MainWindow", u"Preview", None))
            self.label.setText(QCoreApplication.translate("MainWindow", u"TextLabel", None))
            self.label.setProperty("class", QCoreApplication.translate("MainWindow", u"big-label", None))
            self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QCoreApplication.translate("MainWindow", u"Tab 1", None))
            self.label_2.setText(QCoreApplication.translate("MainWindow", u"TextLabel", None))
            self.label_2.setProperty("class", QCoreApplication.translate("MainWindow", u"big-label", None))
            self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QCoreApplication.translate("MainWindow", u"Tab 2", None))
            self.label_3.setText(QCoreApplication.translate("MainWindow", u"TextLabel", None))
            self.label_3.setProperty("class", QCoreApplication.translate("MainWindow", u"big-label", None))
            self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), QCoreApplication.translate("MainWindow", u"\u30da\u30fc\u30b8", None))
        # retranslateUi
    
[/code]


CC BY-SA 4.0
2022-10-24T10:38:40.300
91791
2022-10-24T10:38:40.300
50560
question
python python3 qt pyqt pyside
PySide6でQTabWidgetのタブ数を３つにすると最初のタブだけstylesheetが適用されない