0

我在 Windows 10 上的 Python 3.9.6 x64 上使用 PyQt6 6.1.0,我想知道如何自定义 QMessageBox 的标题栏。

在我的项目中,一切都是深色主题,我已经使用QStyleSheet自定义了所有可以被QStyleSheet主题化的东西,除了标题栏和QScrollArea,它们与主题不一致。

我已经设法通过使用.setPalette()方法来设置 QScrollArea 的样式,并在这里找到了一种自定义窗口标题栏的方法:https ://stackoverflow.com/a/57571299/16383578 ,但到目前为止我还没有找到任何关于自定义的信息QMessageBox 的标题栏。

我想要的很简单,改变标题栏的字体大小、字体、字体颜色、背景颜色和关闭按钮。

我已经设法使用样式表自定义 QMessageBox 的内容,但是我找不到自定义标题栏的方法,我无法使用样式表来修改它,也无法使用 QPalette 来修改它,因为没有不是标题栏的颜色角色,谷歌搜索数小时无济于事......

但是我找到了一个 QStyle 类并使用我编写的函数递归地列出它的属性,我发现了这个:

<class path="PyQt6.QtWidgets.QStyle">
        <attr name="alignedRect"/>
        <attr name="childEvent"/>
        <attr name="combinedLayoutSpacing"/>
        <attr name="connectNotify"/>
        <attr name="customEvent"/>
        <attr name="disconnectNotify"/>
        <attr name="drawComplexControl"/>
        <attr name="drawControl"/>
        <attr name="drawItemPixmap"/>
        <attr name="drawItemText"/>
        <attr name="drawPrimitive"/>
        <attr name="generatedIconPixmap"/>
        <attr name="hitTestComplexControl"/>
        <attr name="isSignalConnected"/>
        <attr name="itemPixmapRect"/>
        <attr name="itemTextRect"/>
        <attr name="layoutSpacing"/>
        <attr name="name"/>
        <attr name="pixelMetric"/>
        <attr name="polish"/>
        <attr name="proxy"/>
        <attr name="receivers"/>
        <attr name="sender"/>
        <attr name="senderSignalIndex"/>
        <attr name="sizeFromContents"/>
        <attr name="sliderPositionFromValue"/>
        <attr name="sliderValueFromPosition"/>
        <attr name="standardIcon"/>
        <attr name="standardPalette"/>
        <attr name="standardPixmap"/>
        <attr name="styleHint"/>
        <attr name="subControlRect"/>
        <attr name="subElementRect"/>
        <attr name="timerEvent"/>
        <attr name="unpolish"/>
        <attr name="visualAlignment"/>
        <attr name="visualPos"/>
        <attr name="visualRect"/>
        <class path="PyQt6.QtWidgets.QStyle.ComplexControl">
            <attr name="CC_SpinBox"/>
            <attr name="CC_ComboBox"/>
            <attr name="CC_ScrollBar"/>
            <attr name="CC_Slider"/>
            <attr name="CC_ToolButton"/>
            <attr name="CC_TitleBar"/>
            <attr name="CC_Dial"/>
            <attr name="CC_GroupBox"/>
            <attr name="CC_MdiControls"/>
            <attr name="CC_CustomBase"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.ContentsType">
            <attr name="CT_PushButton"/>
            <attr name="CT_CheckBox"/>
            <attr name="CT_RadioButton"/>
            <attr name="CT_ToolButton"/>
            <attr name="CT_ComboBox"/>
            <attr name="CT_Splitter"/>
            <attr name="CT_ProgressBar"/>
            <attr name="CT_MenuItem"/>
            <attr name="CT_MenuBarItem"/>
            <attr name="CT_MenuBar"/>
            <attr name="CT_Menu"/>
            <attr name="CT_TabBarTab"/>
            <attr name="CT_Slider"/>
            <attr name="CT_ScrollBar"/>
            <attr name="CT_LineEdit"/>
            <attr name="CT_SpinBox"/>
            <attr name="CT_SizeGrip"/>
            <attr name="CT_TabWidget"/>
            <attr name="CT_DialogButtons"/>
            <attr name="CT_HeaderSection"/>
            <attr name="CT_GroupBox"/>
            <attr name="CT_MdiControls"/>
            <attr name="CT_ItemViewItem"/>
            <attr name="CT_CustomBase"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.ControlElement">
            <attr name="CE_PushButton"/>
            <attr name="CE_PushButtonBevel"/>
            <attr name="CE_PushButtonLabel"/>
            <attr name="CE_CheckBox"/>
            <attr name="CE_CheckBoxLabel"/>
            <attr name="CE_RadioButton"/>
            <attr name="CE_RadioButtonLabel"/>
            <attr name="CE_TabBarTab"/>
            <attr name="CE_TabBarTabShape"/>
            <attr name="CE_TabBarTabLabel"/>
            <attr name="CE_ProgressBar"/>
            <attr name="CE_ProgressBarGroove"/>
            <attr name="CE_ProgressBarContents"/>
            <attr name="CE_ProgressBarLabel"/>
            <attr name="CE_MenuItem"/>
            <attr name="CE_MenuScroller"/>
            <attr name="CE_MenuVMargin"/>
            <attr name="CE_MenuHMargin"/>
            <attr name="CE_MenuTearoff"/>
            <attr name="CE_MenuEmptyArea"/>
            <attr name="CE_MenuBarItem"/>
            <attr name="CE_MenuBarEmptyArea"/>
            <attr name="CE_ToolButtonLabel"/>
            <attr name="CE_Header"/>
            <attr name="CE_HeaderSection"/>
            <attr name="CE_HeaderLabel"/>
            <attr name="CE_ToolBoxTab"/>
            <attr name="CE_SizeGrip"/>
            <attr name="CE_Splitter"/>
            <attr name="CE_RubberBand"/>
            <attr name="CE_DockWidgetTitle"/>
            <attr name="CE_ScrollBarAddLine"/>
            <attr name="CE_ScrollBarSubLine"/>
            <attr name="CE_ScrollBarAddPage"/>
            <attr name="CE_ScrollBarSubPage"/>
            <attr name="CE_ScrollBarSlider"/>
            <attr name="CE_ScrollBarFirst"/>
            <attr name="CE_ScrollBarLast"/>
            <attr name="CE_FocusFrame"/>
            <attr name="CE_ComboBoxLabel"/>
            <attr name="CE_ToolBar"/>
            <attr name="CE_ToolBoxTabShape"/>
            <attr name="CE_ToolBoxTabLabel"/>
            <attr name="CE_HeaderEmptyArea"/>
            <attr name="CE_ColumnViewGrip"/>
            <attr name="CE_ItemViewItem"/>
            <attr name="CE_ShapedFrame"/>
            <attr name="CE_CustomBase"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.PixelMetric">
            <attr name="PM_ButtonMargin"/>
            <attr name="PM_ButtonDefaultIndicator"/>
            <attr name="PM_MenuButtonIndicator"/>
            <attr name="PM_ButtonShiftHorizontal"/>
            <attr name="PM_ButtonShiftVertical"/>
            <attr name="PM_DefaultFrameWidth"/>
            <attr name="PM_SpinBoxFrameWidth"/>
            <attr name="PM_ComboBoxFrameWidth"/>
            <attr name="PM_MaximumDragDistance"/>
            <attr name="PM_ScrollBarExtent"/>
            <attr name="PM_ScrollBarSliderMin"/>
            <attr name="PM_SliderThickness"/>
            <attr name="PM_SliderControlThickness"/>
            <attr name="PM_SliderLength"/>
            <attr name="PM_SliderTickmarkOffset"/>
            <attr name="PM_SliderSpaceAvailable"/>
            <attr name="PM_DockWidgetSeparatorExtent"/>
            <attr name="PM_DockWidgetHandleExtent"/>
            <attr name="PM_DockWidgetFrameWidth"/>
            <attr name="PM_TabBarTabOverlap"/>
            <attr name="PM_TabBarTabHSpace"/>
            <attr name="PM_TabBarTabVSpace"/>
            <attr name="PM_TabBarBaseHeight"/>
            <attr name="PM_TabBarBaseOverlap"/>
            <attr name="PM_ProgressBarChunkWidth"/>
            <attr name="PM_SplitterWidth"/>
            <attr name="PM_TitleBarHeight"/>
            <attr name="PM_MenuScrollerHeight"/>
            <attr name="PM_MenuHMargin"/>
            <attr name="PM_MenuVMargin"/>
            <attr name="PM_MenuPanelWidth"/>
            <attr name="PM_MenuTearoffHeight"/>
            <attr name="PM_MenuDesktopFrameWidth"/>
            <attr name="PM_MenuBarPanelWidth"/>
            <attr name="PM_MenuBarItemSpacing"/>
            <attr name="PM_MenuBarVMargin"/>
            <attr name="PM_MenuBarHMargin"/>
            <attr name="PM_IndicatorWidth"/>
            <attr name="PM_IndicatorHeight"/>
            <attr name="PM_ExclusiveIndicatorWidth"/>
            <attr name="PM_ExclusiveIndicatorHeight"/>
            <attr name="PM_DialogButtonsSeparator"/>
            <attr name="PM_DialogButtonsButtonWidth"/>
            <attr name="PM_DialogButtonsButtonHeight"/>
            <attr name="PM_MdiSubWindowFrameWidth"/>
            <attr name="PM_MdiSubWindowMinimizedWidth"/>
            <attr name="PM_HeaderMargin"/>
            <attr name="PM_HeaderMarkSize"/>
            <attr name="PM_HeaderGripMargin"/>
            <attr name="PM_TabBarTabShiftHorizontal"/>
            <attr name="PM_TabBarTabShiftVertical"/>
            <attr name="PM_TabBarScrollButtonWidth"/>
            <attr name="PM_ToolBarFrameWidth"/>
            <attr name="PM_ToolBarHandleExtent"/>
            <attr name="PM_ToolBarItemSpacing"/>
            <attr name="PM_ToolBarItemMargin"/>
            <attr name="PM_ToolBarSeparatorExtent"/>
            <attr name="PM_ToolBarExtensionExtent"/>
            <attr name="PM_SpinBoxSliderHeight"/>
            <attr name="PM_ToolBarIconSize"/>
            <attr name="PM_ListViewIconSize"/>
            <attr name="PM_IconViewIconSize"/>
            <attr name="PM_SmallIconSize"/>
            <attr name="PM_LargeIconSize"/>
            <attr name="PM_FocusFrameVMargin"/>
            <attr name="PM_FocusFrameHMargin"/>
            <attr name="PM_ToolTipLabelFrameWidth"/>
            <attr name="PM_CheckBoxLabelSpacing"/>
            <attr name="PM_TabBarIconSize"/>
            <attr name="PM_SizeGripSize"/>
            <attr name="PM_DockWidgetTitleMargin"/>
            <attr name="PM_MessageBoxIconSize"/>
            <attr name="PM_ButtonIconSize"/>
            <attr name="PM_DockWidgetTitleBarButtonMargin"/>
            <attr name="PM_RadioButtonLabelSpacing"/>
            <attr name="PM_LayoutLeftMargin"/>
            <attr name="PM_LayoutTopMargin"/>
            <attr name="PM_LayoutRightMargin"/>
            <attr name="PM_LayoutBottomMargin"/>
            <attr name="PM_LayoutHorizontalSpacing"/>
            <attr name="PM_LayoutVerticalSpacing"/>
            <attr name="PM_TabBar_ScrollButtonOverlap"/>
            <attr name="PM_TextCursorWidth"/>
            <attr name="PM_TabCloseIndicatorWidth"/>
            <attr name="PM_TabCloseIndicatorHeight"/>
            <attr name="PM_ScrollView_ScrollBarSpacing"/>
            <attr name="PM_SubMenuOverlap"/>
            <attr name="PM_ScrollView_ScrollBarOverlap"/>
            <attr name="PM_TreeViewIndentation"/>
            <attr name="PM_HeaderDefaultSectionSizeHorizontal"/>
            <attr name="PM_HeaderDefaultSectionSizeVertical"/>
            <attr name="PM_TitleBarButtonIconSize"/>
            <attr name="PM_TitleBarButtonSize"/>
            <attr name="PM_CustomBase"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.PrimitiveElement">
            <attr name="PE_Frame"/>
            <attr name="PE_FrameDefaultButton"/>
            <attr name="PE_FrameDockWidget"/>
            <attr name="PE_FrameFocusRect"/>
            <attr name="PE_FrameGroupBox"/>
            <attr name="PE_FrameLineEdit"/>
            <attr name="PE_FrameMenu"/>
            <attr name="PE_FrameTabWidget"/>
            <attr name="PE_FrameWindow"/>
            <attr name="PE_FrameButtonBevel"/>
            <attr name="PE_FrameButtonTool"/>
            <attr name="PE_FrameTabBarBase"/>
            <attr name="PE_PanelButtonCommand"/>
            <attr name="PE_PanelButtonBevel"/>
            <attr name="PE_PanelButtonTool"/>
            <attr name="PE_PanelMenuBar"/>
            <attr name="PE_PanelToolBar"/>
            <attr name="PE_PanelLineEdit"/>
            <attr name="PE_IndicatorArrowDown"/>
            <attr name="PE_IndicatorArrowLeft"/>
            <attr name="PE_IndicatorArrowRight"/>
            <attr name="PE_IndicatorArrowUp"/>
            <attr name="PE_IndicatorBranch"/>
            <attr name="PE_IndicatorButtonDropDown"/>
            <attr name="PE_IndicatorCheckBox"/>
            <attr name="PE_IndicatorDockWidgetResizeHandle"/>
            <attr name="PE_IndicatorHeaderArrow"/>
            <attr name="PE_IndicatorMenuCheckMark"/>
            <attr name="PE_IndicatorProgressChunk"/>
            <attr name="PE_IndicatorRadioButton"/>
            <attr name="PE_IndicatorSpinDown"/>
            <attr name="PE_IndicatorSpinMinus"/>
            <attr name="PE_IndicatorSpinPlus"/>
            <attr name="PE_IndicatorSpinUp"/>
            <attr name="PE_IndicatorToolBarHandle"/>
            <attr name="PE_IndicatorToolBarSeparator"/>
            <attr name="PE_PanelTipLabel"/>
            <attr name="PE_IndicatorTabTear"/>
            <attr name="PE_PanelScrollAreaCorner"/>
            <attr name="PE_Widget"/>
            <attr name="PE_IndicatorColumnViewArrow"/>
            <attr name="PE_FrameStatusBarItem"/>
            <attr name="PE_IndicatorItemViewItemCheck"/>
            <attr name="PE_IndicatorItemViewItemDrop"/>
            <attr name="PE_PanelItemViewItem"/>
            <attr name="PE_PanelItemViewRow"/>
            <attr name="PE_PanelStatusBar"/>
            <attr name="PE_IndicatorTabClose"/>
            <attr name="PE_PanelMenu"/>
            <attr name="PE_IndicatorTabTearRight"/>
            <attr name="PE_CustomBase"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.RequestSoftwareInputPanel">
            <attr name="RSIP_OnMouseClickAndAlreadyFocused"/>
            <attr name="RSIP_OnMouseClick"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.StandardPixmap">
            <attr name="SP_TitleBarMenuButton"/>
            <attr name="SP_TitleBarMinButton"/>
            <attr name="SP_TitleBarMaxButton"/>
            <attr name="SP_TitleBarCloseButton"/>
            <attr name="SP_TitleBarNormalButton"/>
            <attr name="SP_TitleBarShadeButton"/>
            <attr name="SP_TitleBarUnshadeButton"/>
            <attr name="SP_TitleBarContextHelpButton"/>
            <attr name="SP_DockWidgetCloseButton"/>
            <attr name="SP_MessageBoxInformation"/>
            <attr name="SP_MessageBoxWarning"/>
            <attr name="SP_MessageBoxCritical"/>
            <attr name="SP_MessageBoxQuestion"/>
            <attr name="SP_DesktopIcon"/>
            <attr name="SP_TrashIcon"/>
            <attr name="SP_ComputerIcon"/>
            <attr name="SP_DriveFDIcon"/>
            <attr name="SP_DriveHDIcon"/>
            <attr name="SP_DriveCDIcon"/>
            <attr name="SP_DriveDVDIcon"/>
            <attr name="SP_DriveNetIcon"/>
            <attr name="SP_DirOpenIcon"/>
            <attr name="SP_DirClosedIcon"/>
            <attr name="SP_DirLinkIcon"/>
            <attr name="SP_FileIcon"/>
            <attr name="SP_FileLinkIcon"/>
            <attr name="SP_ToolBarHorizontalExtensionButton"/>
            <attr name="SP_ToolBarVerticalExtensionButton"/>
            <attr name="SP_FileDialogStart"/>
            <attr name="SP_FileDialogEnd"/>
            <attr name="SP_FileDialogToParent"/>
            <attr name="SP_FileDialogNewFolder"/>
            <attr name="SP_FileDialogDetailedView"/>
            <attr name="SP_FileDialogInfoView"/>
            <attr name="SP_FileDialogContentsView"/>
            <attr name="SP_FileDialogListView"/>
            <attr name="SP_FileDialogBack"/>
            <attr name="SP_DirIcon"/>
            <attr name="SP_DialogOkButton"/>
            <attr name="SP_DialogCancelButton"/>
            <attr name="SP_DialogHelpButton"/>
            <attr name="SP_DialogOpenButton"/>
            <attr name="SP_DialogSaveButton"/>
            <attr name="SP_DialogCloseButton"/>
            <attr name="SP_DialogApplyButton"/>
            <attr name="SP_DialogResetButton"/>
            <attr name="SP_DialogDiscardButton"/>
            <attr name="SP_DialogYesButton"/>
            <attr name="SP_DialogNoButton"/>
            <attr name="SP_ArrowUp"/>
            <attr name="SP_ArrowDown"/>
            <attr name="SP_ArrowLeft"/>
            <attr name="SP_ArrowRight"/>
            <attr name="SP_ArrowBack"/>
            <attr name="SP_ArrowForward"/>
            <attr name="SP_DirHomeIcon"/>
            <attr name="SP_CommandLink"/>
            <attr name="SP_VistaShield"/>
            <attr name="SP_BrowserReload"/>
            <attr name="SP_BrowserStop"/>
            <attr name="SP_MediaPlay"/>
            <attr name="SP_MediaStop"/>
            <attr name="SP_MediaPause"/>
            <attr name="SP_MediaSkipForward"/>
            <attr name="SP_MediaSkipBackward"/>
            <attr name="SP_MediaSeekForward"/>
            <attr name="SP_MediaSeekBackward"/>
            <attr name="SP_MediaVolume"/>
            <attr name="SP_MediaVolumeMuted"/>
            <attr name="SP_DirLinkOpenIcon"/>
            <attr name="SP_LineEditClearButton"/>
            <attr name="SP_DialogYesToAllButton"/>
            <attr name="SP_DialogNoToAllButton"/>
            <attr name="SP_DialogSaveAllButton"/>
            <attr name="SP_DialogAbortButton"/>
            <attr name="SP_DialogRetryButton"/>
            <attr name="SP_DialogIgnoreButton"/>
            <attr name="SP_RestoreDefaultsButton"/>
            <attr name="SP_CustomBase"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.StateFlag">
            <attr name="State_None"/>
            <attr name="State_Enabled"/>
            <attr name="State_Raised"/>
            <attr name="State_Sunken"/>
            <attr name="State_Off"/>
            <attr name="State_NoChange"/>
            <attr name="State_On"/>
            <attr name="State_DownArrow"/>
            <attr name="State_Horizontal"/>
            <attr name="State_HasFocus"/>
            <attr name="State_Top"/>
            <attr name="State_Bottom"/>
            <attr name="State_FocusAtBorder"/>
            <attr name="State_AutoRaise"/>
            <attr name="State_MouseOver"/>
            <attr name="State_UpArrow"/>
            <attr name="State_Selected"/>
            <attr name="State_Active"/>
            <attr name="State_Open"/>
            <attr name="State_Children"/>
            <attr name="State_Item"/>
            <attr name="State_Sibling"/>
            <attr name="State_Editing"/>
            <attr name="State_KeyboardFocusChange"/>
            <attr name="State_ReadOnly"/>
            <attr name="State_Window"/>
            <attr name="State_Small"/>
            <attr name="State_Mini"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.StyleHint">
            <attr name="SH_EtchDisabledText"/>
            <attr name="SH_DitherDisabledText"/>
            <attr name="SH_ScrollBar_MiddleClickAbsolutePosition"/>
            <attr name="SH_ScrollBar_ScrollWhenPointerLeavesControl"/>
            <attr name="SH_TabBar_SelectMouseType"/>
            <attr name="SH_TabBar_Alignment"/>
            <attr name="SH_Header_ArrowAlignment"/>
            <attr name="SH_Slider_SnapToValue"/>
            <attr name="SH_Slider_SloppyKeyEvents"/>
            <attr name="SH_ProgressDialog_CenterCancelButton"/>
            <attr name="SH_ProgressDialog_TextLabelAlignment"/>
            <attr name="SH_PrintDialog_RightAlignButtons"/>
            <attr name="SH_MainWindow_SpaceBelowMenuBar"/>
            <attr name="SH_FontDialog_SelectAssociatedText"/>
            <attr name="SH_Menu_AllowActiveAndDisabled"/>
            <attr name="SH_Menu_SpaceActivatesItem"/>
            <attr name="SH_Menu_SubMenuPopupDelay"/>
            <attr name="SH_ScrollView_FrameOnlyAroundContents"/>
            <attr name="SH_MenuBar_AltKeyNavigation"/>
            <attr name="SH_ComboBox_ListMouseTracking"/>
            <attr name="SH_Menu_MouseTracking"/>
            <attr name="SH_MenuBar_MouseTracking"/>
            <attr name="SH_ItemView_ChangeHighlightOnFocus"/>
            <attr name="SH_Widget_ShareActivation"/>
            <attr name="SH_Workspace_FillSpaceOnMaximize"/>
            <attr name="SH_ComboBox_Popup"/>
            <attr name="SH_TitleBar_NoBorder"/>
            <attr name="SH_BlinkCursorWhenTextSelected"/>
            <attr name="SH_RichText_FullWidthSelection"/>
            <attr name="SH_Menu_Scrollable"/>
            <attr name="SH_GroupBox_TextLabelVerticalAlignment"/>
            <attr name="SH_GroupBox_TextLabelColor"/>
            <attr name="SH_Menu_SloppySubMenus"/>
            <attr name="SH_Table_GridLineColor"/>
            <attr name="SH_LineEdit_PasswordCharacter"/>
            <attr name="SH_DialogButtons_DefaultButton"/>
            <attr name="SH_ToolBox_SelectedPageTitleBold"/>
            <attr name="SH_TabBar_PreferNoArrows"/>
            <attr name="SH_ScrollBar_LeftClickAbsolutePosition"/>
            <attr name="SH_UnderlineShortcut"/>
            <attr name="SH_SpinBox_AnimateButton"/>
            <attr name="SH_SpinBox_KeyPressAutoRepeatRate"/>
            <attr name="SH_SpinBox_ClickAutoRepeatRate"/>
            <attr name="SH_Menu_FillScreenWithScroll"/>
            <attr name="SH_ToolTipLabel_Opacity"/>
            <attr name="SH_DrawMenuBarSeparator"/>
            <attr name="SH_TitleBar_ModifyNotification"/>
            <attr name="SH_Button_FocusPolicy"/>
            <attr name="SH_MessageBox_UseBorderForButtonSpacing"/>
            <attr name="SH_TitleBar_AutoRaise"/>
            <attr name="SH_ToolButton_PopupDelay"/>
            <attr name="SH_FocusFrame_Mask"/>
            <attr name="SH_RubberBand_Mask"/>
            <attr name="SH_WindowFrame_Mask"/>
            <attr name="SH_SpinControls_DisableOnBounds"/>
            <attr name="SH_Dial_BackgroundRole"/>
            <attr name="SH_ComboBox_LayoutDirection"/>
            <attr name="SH_ItemView_EllipsisLocation"/>
            <attr name="SH_ItemView_ShowDecorationSelected"/>
            <attr name="SH_ItemView_ActivateItemOnSingleClick"/>
            <attr name="SH_ScrollBar_ContextMenu"/>
            <attr name="SH_ScrollBar_RollBetweenButtons"/>
            <attr name="SH_Slider_StopMouseOverSlider"/>
            <attr name="SH_Slider_AbsoluteSetButtons"/>
            <attr name="SH_Slider_PageSetButtons"/>
            <attr name="SH_Menu_KeyboardSearch"/>
            <attr name="SH_TabBar_ElideMode"/>
            <attr name="SH_DialogButtonLayout"/>
            <attr name="SH_ComboBox_PopupFrameStyle"/>
            <attr name="SH_MessageBox_TextInteractionFlags"/>
            <attr name="SH_DialogButtonBox_ButtonsHaveIcons"/>
            <attr name="SH_MessageBox_CenterButtons"/>
            <attr name="SH_Menu_SelectionWrap"/>
            <attr name="SH_ItemView_MovementWithoutUpdatingSelection"/>
            <attr name="SH_ToolTip_Mask"/>
            <attr name="SH_FocusFrame_AboveWidget"/>
            <attr name="SH_TextControl_FocusIndicatorTextCharFormat"/>
            <attr name="SH_WizardStyle"/>
            <attr name="SH_ItemView_ArrowKeysNavigateIntoChildren"/>
            <attr name="SH_Menu_Mask"/>
            <attr name="SH_Menu_FlashTriggeredItem"/>
            <attr name="SH_Menu_FadeOutOnHide"/>
            <attr name="SH_SpinBox_ClickAutoRepeatThreshold"/>
            <attr name="SH_ItemView_PaintAlternatingRowColorsForEmptyArea"/>
            <attr name="SH_FormLayoutWrapPolicy"/>
            <attr name="SH_TabWidget_DefaultTabPosition"/>
            <attr name="SH_ToolBar_Movable"/>
            <attr name="SH_FormLayoutFieldGrowthPolicy"/>
            <attr name="SH_FormLayoutFormAlignment"/>
            <attr name="SH_FormLayoutLabelAlignment"/>
            <attr name="SH_ItemView_DrawDelegateFrame"/>
            <attr name="SH_TabBar_CloseButtonPosition"/>
            <attr name="SH_DockWidget_ButtonsHaveFrame"/>
            <attr name="SH_ToolButtonStyle"/>
            <attr name="SH_RequestSoftwareInputPanel"/>
            <attr name="SH_ListViewExpand_SelectMouseType"/>
            <attr name="SH_ScrollBar_Transient"/>
            <attr name="SH_Menu_SupportsSections"/>
            <attr name="SH_ToolTip_WakeUpDelay"/>
            <attr name="SH_ToolTip_FallAsleepDelay"/>
            <attr name="SH_Widget_Animate"/>
            <attr name="SH_Splitter_OpaqueResize"/>
            <attr name="SH_LineEdit_PasswordMaskDelay"/>
            <attr name="SH_TabBar_ChangeCurrentDelay"/>
            <attr name="SH_Menu_SubMenuUniDirection"/>
            <attr name="SH_Menu_SubMenuUniDirectionFailCount"/>
            <attr name="SH_Menu_SubMenuSloppySelectOtherActions"/>
            <attr name="SH_Menu_SubMenuSloppyCloseTimeout"/>
            <attr name="SH_Menu_SubMenuResetWhenReenteringParent"/>
            <attr name="SH_Menu_SubMenuDontStartSloppyOnLeave"/>
            <attr name="SH_ItemView_ScrollMode"/>
            <attr name="SH_TitleBar_ShowToolTipsOnButtons"/>
            <attr name="SH_Widget_Animation_Duration"/>
            <attr name="SH_ComboBox_AllowWheelScrolling"/>
            <attr name="SH_SpinBox_ButtonsInsideFrame"/>
            <attr name="SH_SpinBox_StepModifier"/>
            <attr name="SH_CustomBase"/>
            <attr name="SH_TabBar_AllowWheelScrolling"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.SubControl">
            <attr name="SC_None"/>
            <attr name="SC_ScrollBarAddLine"/>
            <attr name="SC_ScrollBarSubLine"/>
            <attr name="SC_ScrollBarAddPage"/>
            <attr name="SC_ScrollBarSubPage"/>
            <attr name="SC_ScrollBarFirst"/>
            <attr name="SC_ScrollBarLast"/>
            <attr name="SC_ScrollBarSlider"/>
            <attr name="SC_ScrollBarGroove"/>
            <attr name="SC_TitleBarLabel"/>
            <attr name="SC_CustomBase"/>
            <attr name="SC_All"/>
        </class>
        <class path="PyQt6.QtWidgets.QStyle.SubElement">
            <attr name="SE_PushButtonContents"/>
            <attr name="SE_PushButtonFocusRect"/>
            <attr name="SE_CheckBoxIndicator"/>
            <attr name="SE_CheckBoxContents"/>
            <attr name="SE_CheckBoxFocusRect"/>
            <attr name="SE_CheckBoxClickRect"/>
            <attr name="SE_RadioButtonIndicator"/>
            <attr name="SE_RadioButtonContents"/>
            <attr name="SE_RadioButtonFocusRect"/>
            <attr name="SE_RadioButtonClickRect"/>
            <attr name="SE_ComboBoxFocusRect"/>
            <attr name="SE_SliderFocusRect"/>
            <attr name="SE_ProgressBarGroove"/>
            <attr name="SE_ProgressBarContents"/>
            <attr name="SE_ProgressBarLabel"/>
            <attr name="SE_ToolBoxTabContents"/>
            <attr name="SE_HeaderLabel"/>
            <attr name="SE_HeaderArrow"/>
            <attr name="SE_TabWidgetTabBar"/>
            <attr name="SE_TabWidgetTabPane"/>
            <attr name="SE_TabWidgetTabContents"/>
            <attr name="SE_TabWidgetLeftCorner"/>
            <attr name="SE_TabWidgetRightCorner"/>
            <attr name="SE_TabBarTearIndicator"/>
            <attr name="SE_TreeViewDisclosureItem"/>
            <attr name="SE_LineEditContents"/>
            <attr name="SE_FrameContents"/>
            <attr name="SE_DockWidgetCloseButton"/>
            <attr name="SE_DockWidgetFloatButton"/>
            <attr name="SE_DockWidgetTitleBarText"/>
            <attr name="SE_DockWidgetIcon"/>
            <attr name="SE_CheckBoxLayoutItem"/>
            <attr name="SE_ComboBoxLayoutItem"/>
            <attr name="SE_DateTimeEditLayoutItem"/>
            <attr name="SE_LabelLayoutItem"/>
            <attr name="SE_ProgressBarLayoutItem"/>
            <attr name="SE_PushButtonLayoutItem"/>
            <attr name="SE_RadioButtonLayoutItem"/>
            <attr name="SE_SliderLayoutItem"/>
            <attr name="SE_SpinBoxLayoutItem"/>
            <attr name="SE_ToolButtonLayoutItem"/>
            <attr name="SE_FrameLayoutItem"/>
            <attr name="SE_GroupBoxLayoutItem"/>
            <attr name="SE_TabWidgetLayoutItem"/>
            <attr name="SE_ItemViewItemCheckIndicator"/>
            <attr name="SE_ItemViewItemDecoration"/>
            <attr name="SE_ItemViewItemText"/>
            <attr name="SE_ItemViewItemFocusRect"/>
            <attr name="SE_TabBarTabLeftButton"/>
            <attr name="SE_TabBarTabRightButton"/>
            <attr name="SE_TabBarTabText"/>
            <attr name="SE_ShapedFrameContents"/>
            <attr name="SE_ToolBarHandle"/>
            <attr name="SE_TabBarScrollLeftButton"/>
            <attr name="SE_TabBarScrollRightButton"/>
            <attr name="SE_TabBarTearIndicatorRight"/>
            <attr name="SE_PushButtonBevel"/>
            <attr name="SE_CustomBase"/>
        </class>
    </class>

我从未使用过 QStyle,但属性中出现了 19 次标题栏,所以我想它是相关的,它似乎能够实现我想要的,但我不知道如何使用它。

那么如何自定义 QMessageBox 的标题栏呢?

4

0 回答 0