QStyleOptionMenuItem 类是用于绘制菜单项的必要描述参数。 更多...
头: | #include <QStyleOptionMenuItem> |
CMake: |
find_package(Qt6 COMPONENTS Widgets REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
继承: | QStyleOption |
enum | CheckType { NotCheckable, Exclusive, NonExclusive } |
enum | MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, …, EmptyArea } |
enum | StyleOptionType { Type } |
enum | StyleOptionVersion { Version } |
QStyleOptionMenuItem (const QStyleOptionMenuItem & other ) | |
QStyleOptionMenuItem () |
QStyleOptionMenuItem::CheckType | checkType |
bool | checked |
QFont | font |
QIcon | icon |
int | maxIconWidth |
bool | menuHasCheckableItems |
QStyleOptionMenuItem::MenuItemType | menuItemType |
QRect | menuRect |
int | reservedShortcutWidth |
QString | text |
QStyleOptionMenuItem 包含所有信息当 QStyle 函数需要绘制菜单项从 QMenu 。它还用于绘制其它相关菜单 Widget。
出于性能原因,有很少成员函数,且对成员变量的访问是直接的 (即:使用
.
or
->
运算符)。这使结构易于使用并强调这些只需通过样式函数使用参数。
对于可以如何使用样式选项的演示范例,见 样式 范例。
另请参阅 QStyleOption .
此枚举用于指示是否应该为项绘制复选标记,或者即使根本不应该绘制复选标记。
常量 | 值 | 描述 |
---|---|---|
QStyleOptionMenuItem::NotCheckable
|
0
|
项不可复选。 |
QStyleOptionMenuItem::Exclusive
|
1
|
项是独占复选项 (像:单选按钮)。 |
QStyleOptionMenuItem::NonExclusive
|
2
|
项是非独占复选项 (像:复选框)。 |
另请参阅 checkType , QAction::checkable , QAction::checked ,和 QActionGroup::exclusionPolicy .
此枚举指示结构描述的菜单项类型。
常量 | 值 | 描述 |
---|---|---|
QStyleOptionMenuItem::Normal
|
0
|
正常菜单项。 |
QStyleOptionMenuItem::DefaultItem
|
1
|
菜单项是默认动作如指定采用 QMenu::defaultAction (). |
QStyleOptionMenuItem::Separator
|
2
|
菜单分隔符。 |
QStyleOptionMenuItem::SubMenu
|
3
|
指示菜单项指向子菜单。 |
QStyleOptionMenuItem::Scroller
|
4
|
弹出菜单滚动条 (目前仅用于 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 .
构造副本为 other 样式选项。
Constructs a QStyleOptionMenuItem, initializing the members variables to their default values.
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.