QStyleHintReturn Class
QStyleHintReturn 类提供返回基本数据类型以外的样式提示。更多
Header: | #include <QStyleHintReturn> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
继承于 |
公共类型
enum | HintReturnType { SH_Default, SH_Mask, SH_Variant } |
enum | StyleOptionType { Type } |
enum | StyleOptionVersion { Version } |
公共函数
QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default) |
公共变量
相关非成员
T | qstyleoption_cast(const QStyleHintReturn *hint) |
T | qstyleoption_cast(QStyleHintReturn *hint) |
详细说明
QStyleHintReturn 及其子类用于将样式信息传递回查询 widget。当来自QStyle::styleHint() 的返回值不能提供足够的细节时,例如,当要返回一个掩码时,该函数最为有用。
成员类型文档
enum QStyleHintReturn::HintReturnType
常数 | 值 | 说明 |
---|---|---|
QStyleHintReturn::SH_Default | 0xf000 | QStyleHintReturn |
QStyleHintReturn::SH_Mask | 0xf001 | QStyle::SH_RubberBand_Mask QStyle::SH_FocusFrame_Mask |
QStyleHintReturn::SH_Variant | 0xf002 | QStyle::SH_TextControl_FocusIndicatorTextCharFormat |
enum QStyleHintReturn::StyleOptionType
该枚举用于保存有关样式选项类型的信息,并为每个QStyleHintReturn 子类定义。
常量 | 值 | 描述 |
---|---|---|
QStyleHintReturn::Type | SH_Default | 提供的样式选项的类型(SH_Default 适用于该类)。 |
QStyleHintReturn 及其子类和qstyleoption_cast() 内部使用该类型来确定样式选项的类型。一般来说,除非您想创建自己的QStyleHintReturn 子类和自己的样式,否则不需要担心这个问题。
另请参见 StyleOptionVersion 。
enum QStyleHintReturn::StyleOptionVersion
该枚举用于保存有关样式选项版本的信息,并为每个QStyleHintReturn 子类定义。
常量 | 值 | 说明 |
---|---|---|
QStyleHintReturn::Version | 1 | 1 |
版本用于QStyleHintReturn 子类在不破坏兼容性的情况下实现扩展。如果使用qstyleoption_cast() ,通常不需要检查它。
另请参阅 StyleOptionType 。
成员函数文档
QStyleHintReturn::QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default)
构造一个版本为version 、类型为type 的 QStyleHintReturn。
版本对 QStyleHintReturn 没有特殊意义;子类可以用它来区分同一提示类型的不同版本。
成员变量文档
int QStyleHintReturn::type
该变量用于保存样式提示容器的类型。
另请参见 HintReturnType 。
int QStyleHintReturn::version
该变量用于保存返回容器样式提示的版本。
子类可以使用此值来实现扩展,而不会破坏兼容性。如果使用qstyleoption_cast<T>(),通常不需要检查它。
相关非成员
template <typename T> T qstyleoption_cast(const QStyleHintReturn *hint)
根据hint 的type 和version ,返回 T 或nullptr
。
示例:
int MyStyle::styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn* returnData) const; { if (stylehint == SH_RubberBand_Mask) { const QStyleHintReturnMask *maskReturn = qstyleoption_cast<const QStyleHintReturnMask *>(hint); if (maskReturn) { ... } } ... }
另请参见 QStyleHintReturn::type 和QStyleHintReturn::version 。
template <typename T> T qstyleoption_cast(QStyleHintReturn *hint)
这是一个重载函数。
根据hint 的类型,返回一个 T 或nullptr
。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.