Obsolete Members for QObject
QObject 类的以下成员已被废弃。提供这些成员是为了确保旧源代码能够继续运行。我们强烈建议不要在新代码中使用它们。
宏
宏文档
[deprecated in 5.5] Q_ENUMS(...)
自 5.5 版本起,该宏已被废弃。我们强烈建议不要在新代码中使用它。
在新代码中,应优先使用 `Q_ENUM()` 宏,该宏可使类型在元类型系统中可用。例如,对于使用 `Q_ENUMS()` 声明的类型,QMetaEnum::fromType() 将无法正常工作。
该宏用于将一个或多个枚举类型注册到元对象系统中。
若要注册在另一个类中声明的枚举,该枚举必须通过定义它的类名进行完全限定。此外,定义该枚举的类必须继承QObject ,并使用 Q_ENUMS() 声明该枚举。
另请参阅 Qt 的属性系统。
[deprecated in 5.5] Q_FLAGS(...)
自 5.5 版本起,该宏已被废弃。我们强烈建议不要在新代码中使用它。
该宏将一个或多个flags types 注册到元对象系统中。它通常用于类定义中,用于声明给定枚举的值可作为标志使用,并可通过位或运算符进行组合。
注意:该宏 会自动将各个标志值注册到元对象系统中,因此无需在此宏之外额外使用 `Q_ENUMS()`。
在新代码中,建议优先使用Q_FLAG() 宏,该宏可使该类型对元类型系统也有效。
另请参阅 Qt 的属性系统。
© 2026 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.