开发者

Qt - meta object code

What do we mean by the meta object code when relating to the Meta Object Compiler (moc) 开发者_如何转开发in Qt?

Thanks.


Meta objects enhance programming languages by creating new or manipulate existing objects. They provide functionalities a language does not actually have by itself. The Meta Objects are interpreted either by compile time or run time. In Qt and C++ it is done during compile time by the Meta Object Compiler (moc).

An example case is the usage of the signal/slot concept.


Since you specifically asked about Meta object and moc,

From docs,

...The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes. ...

HTH..


Meta object code is required for Signal Slot mechanism ,Run time type information and dynamic property system.


Qt system creates "meta object code" based on "annotations" in your c++ code (eg Q_PROPERTY, Q_SLOTS etc). Qt uses them to implement meta-calls and reflection style access to class properties.

Look at the ".moc" files that the compiler produces for your class and you'll understand.

But given the uncertainty around Qt's future, may I ask why you are choosing Qt? (unless its purely for the joy of hacking..)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜