1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/metaobjects.doc:36 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>Meta Object System</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Meta Object System</h1>
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | <p> <!-- index meta object --><a name="meta-object"></a><!-- index Q_OBJECT --><a name="Q_OBJECT"></a>
|
---|
37 | <p> Qt's Meta Object System provides the signals and slots mechanism for
|
---|
38 | inter-object communication, runtime type information, and the dynamic
|
---|
39 | property system.
|
---|
40 | <p> The Meta Object System is based on three things:
|
---|
41 | <ol type=1>
|
---|
42 | <li> the <a href="qobject.html">QObject</a> class;
|
---|
43 | <li> the Q_OBJECT macro inside the private section of the class
|
---|
44 | declaration;
|
---|
45 | <li> the <a href="moc.html">Meta Object Compiler (moc)</a>.
|
---|
46 | </ol>
|
---|
47 | <p> The <em><a href="moc.html#moc">moc</a></em> reads a C++ source file. If it finds one or more class
|
---|
48 | declarations that contain the Q_OBJECT macro, it produces another C++
|
---|
49 | source file which contains the meta object code for the classes that
|
---|
50 | contain the Q_OBJECT macro. This generated source file is either
|
---|
51 | #included into the class's source file or compiled and linked with the
|
---|
52 | class's implementation.
|
---|
53 | <p> In addition to providing the <a href="signalsandslots.html">signals and
|
---|
54 | slots</a> mechanism for communication between objects (the main
|
---|
55 | reason for introducing the system), the meta object code provides
|
---|
56 | additional features in QObject:
|
---|
57 | <p> <ul>
|
---|
58 | <p> <li> the <a href="qobject.html#className">className()</a> function that
|
---|
59 | returns the class name as a string at runtime, without requiring
|
---|
60 | native runtime type information (RTTI) support through the C++
|
---|
61 | compiler.
|
---|
62 | <p> <li> the <a href="qobject.html#inherits">inherits()</a> function that
|
---|
63 | returns whether an object is an instance of a class that inherits a
|
---|
64 | specified class within the <a href="qobject.html">QObject</a> inheritance tree.
|
---|
65 | <p> <li> the <a href="qobject.html#tr">tr()</a> and
|
---|
66 | <a href="qobject.html#trUtf8">trUtf8()</a> functions for string
|
---|
67 | translation as used for <a href="i18n.html#internationalization">internationalization</a>.
|
---|
68 | <p> <li> the <a href="qobject.html#setProperty">setProperty()</a> and <a href="qobject.html#property">property()</a> functions for dynamically
|
---|
69 | setting and getting <a href="properties.html">object properties</a> by
|
---|
70 | name.
|
---|
71 | <p> <li> the <a href="qobject.html#metaObject">metaObject()</a> function that
|
---|
72 | returns the associated <a href="qmetaobject.html">meta object</a> for the
|
---|
73 | class.
|
---|
74 | <p> </ul>
|
---|
75 | <p> While it is possible to use QObject as a base class without the
|
---|
76 | Q_OBJECT macro and without meta object code, neither signals and slots
|
---|
77 | nor the other features described here will be available if the
|
---|
78 | Q_OBJECT macro is not used. From the meta object system's point of
|
---|
79 | view, a QObject subclass without meta code is equivalent to its
|
---|
80 | closest ancestor with meta object code. This means for example, that
|
---|
81 | className() will not return the actual name of your class, but the
|
---|
82 | class name of this ancestor. We <em>strongly</em> recommend that all
|
---|
83 | subclasses of <a href="qobject.html">QObject</a> use the Q_OBJECT macro regardless of whether
|
---|
84 | they actually use signals, slots and properties or not.
|
---|
85 | <p>
|
---|
86 | <!-- eof -->
|
---|
87 | <p><address><hr><div align=center>
|
---|
88 | <table width=100% cellspacing=0 border=0><tr>
|
---|
89 | <td>Copyright © 2007
|
---|
90 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
91 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
92 | </table></div></address></body>
|
---|
93 | </html>
|
---|