关闭

meta-object system和property system

403人阅读 评论(0) 收藏 举报
 一:The meta-object system is based on three things:
  1. The QObject class provides a base class for objects that can take advantage of the meta-object system.
  2. The Q_OBJECT macro inside the private section of the class declaration is used to enable meta-object features, such as dynamic properties, signals, and slots.
  3. The Meta-Object Compiler (moc) supplies each QObject subclass with the necessary code to implement meta-object features.

The moc tool reads a C++ source file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces another C++ source file which contains the meta-object code for each of those classes. This generated source file is either #include'd into the class's source file or, more usually, compiled and linked with the class's implementation.

In addition to providing the signals and slots mechanism for communication between objects (the main reason for introducing the system), the meta-object code provides the following additional features:

二:QMetaObject

The Qt Meta-Object System in Qt is responsible for the signals and slots inter-object communication mechanism, runtime type information, and the Qt property system. A single QMetaObject instance is created for each QObject subclass that is used in an application, and this instance stores all the meta-information for the QObject subclass. This object is available as QObject::metaObject().

This class is not normally required for application programming, but it is useful if you write meta-applications, such as scripting engines or GUI builders.

三:QPropertySystem

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:104008次
    • 积分:1518
    • 等级:
    • 排名:千里之外
    • 原创:42篇
    • 转载:37篇
    • 译文:0篇
    • 评论:8条
    最新评论