The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item. 更多...
| 頭: | #include <QStyleOptionMenuItem> |
| qmake: | QT += widgets |
| 繼承: | QStyleOption |
| enum | CheckType { NotCheckable, Exclusive, NonExclusive } |
| enum | MenuItemType { Normal, DefaultItem, Separator, SubMenu, ..., EmptyArea } |
| enum | StyleOptionType { Type } |
| enum | StyleOptionVersion { Version } |
| QStyleOptionMenuItem () | |
| QStyleOptionMenuItem (const QStyleOptionMenuItem & other ) |
| QStyleOptionMenuItem::CheckType | checkType |
| bool | checked |
| QFont | font |
| QIcon | icon |
| int | maxIconWidth |
| bool | menuHasCheckableItems |
| QStyleOptionMenuItem::MenuItemType | menuItemType |
| QRect | menuRect |
| int | tabWidth |
| QString | text |
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item.
QStyleOptionMenuItem contains all the information that QStyle 函數需要繪製菜單項從 QMenu 。它還用於繪製其它相關菜單 Widget。
For performance reasons, the access to the member variables is direct (i.e., using the
.
or
->
operator). This low-level feel makes the structures straightforward to use and emphasizes that these are simply parameters used by the style functions.
對於可以如何使用樣式選項的演示範例,見 樣式 範例。
另請參閱 QStyleOption .
此枚舉用於指示是否應該為項繪製復選標記,或者即使根本不應該繪製復選標記。
| 常量 | 值 | 描述 |
|---|---|---|
QStyleOptionMenuItem::NotCheckable
|
0
|
項不可復選。 |
QStyleOptionMenuItem::Exclusive
|
1
|
項是獨占復選項 (像:單選按鈕)。 |
QStyleOptionMenuItem::NonExclusive
|
2
|
項是非獨占復選項 (像:復選框)。 |
另請參閱 checkType , QAction::checkable , QAction::checked ,和 QActionGroup::exclusive .
此枚舉指示結構描述的菜單項類型。
| 常量 | 值 | 描述 |
|---|---|---|
QStyleOptionMenuItem::Normal
|
0
|
正常菜單項。 |
QStyleOptionMenuItem::DefaultItem
|
1
|
菜單項是默認動作如指定采用 QMenu::defaultAction (). |
QStyleOptionMenuItem::Separator
|
2
|
菜單分隔符。 |
QStyleOptionMenuItem::SubMenu
|
3
|
指示菜單項指嚮子菜單。 |
QStyleOptionMenuItem::Scroller
|
4
|
A popup menu scroller (currently only used on macOS ). |
QStyleOptionMenuItem::TearOff
|
5
|
菜單的撕離手柄。 |
QStyleOptionMenuItem::Margin
|
6
|
菜單的邊距。 |
QStyleOptionMenuItem::EmptyArea
|
7
|
菜單的空區域。 |
另請參閱 menuItemType .
This enum is used to hold information about the type of the style option, and is defined for each QStyleOption 子類。
| 常量 | 值 | 描述 |
|---|---|---|
QStyleOptionMenuItem::Type
|
SO_MenuItem
|
提供樣式選項的類型 ( SO_MenuItem 對於此類)。 |
類型內部使用通過 QStyleOption ,其子類,和 qstyleoption_cast () to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles.
另請參閱 StyleOptionVersion .
This enum is used to hold information about the version of the style option, and is defined for each QStyleOption 子類。
| 常量 | 值 | 描述 |
|---|---|---|
QStyleOptionMenuItem::Version
|
1
|
1 |
版本的使用通過 QStyleOption 子類以實現擴展在不破壞兼容性的情況下。若使用 qstyleoption_cast (),通常不需要校驗它。
另請參閱 StyleOptionType .
構造 QStyleOptionMenuItem , initializing the members variables to their default values.
構造副本為 other 樣式選項。
This variable holds the type of checkmark of the menu item
默認值為 NotCheckable .
另請參閱 CheckType .
This variable holds whether the menu item is checked or not
默認值為 false。
This variable holds the font used for the menu item text
This is the font that should be used for drawing the menu text minus the shortcut. The shortcut is usually drawn using the painter's font. By default, the application's default font is used.
This variable holds the icon for the menu item
默認值為空圖標 (即:圖標既沒有像素圖,也沒有文件名)。
This variable holds the maximum icon width for the icon in the menu item
This can be used for drawing the icon into the correct place or properly aligning items. The variable must be set regardless of whether or not the menu item has an icon. The default value is 0.
This variable holds whether the menu as a whole has checkable items or not
默認值為 true。
If this option is set to false, then the menu has no checkable items. This makes it possible for GUI styles to save some horizontal space that would normally be used for the check column.
This variable holds the type of menu item
默認值為 Normal .
另請參閱 MenuItemType .
This variable holds the rectangle for the entire menu
The default value is a null rectangle, i.e. a rectangle with both the width and the height set to 0.
This variable holds the reserved width for the menu item's shortcut
QMenu sets it to the width occupied by the widest shortcut among all visible items within the menu.
默認值為 0。
This variable holds the text for the menu item
Note that the text format is something like this "Menu text \t Shortcut".
If the menu item doesn't have a shortcut, it will just contain the menu item's text. The default value is an empty string.