File: metaobjects.doc

package info (click to toggle)
qt-embedded-free 3.0.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 91,492 kB
  • ctags: 67,431
  • sloc: cpp: 427,709; ansic: 128,011; sh: 21,353; yacc: 2,874; xml: 2,310; python: 1,863; perl: 481; lex: 453; makefile: 426; sql: 29; lisp: 15
file content (103 lines) | stat: -rw-r--r-- 4,181 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/****************************************************************************
** $Id:  qt/metaobjects.doc   3.0.3   edited Nov 27 19:11 $
**
** Explanation of moc and the meta object system
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

/*! \page metaobjects.html

\title Meta Object System

\keyword meta object
\keyword Q_OBJECT

The Meta Object System in Qt is responsible for the signal/slot
mechanism for communication between objects, runtime type information
and the dynamic property system.

It is based on three things:
\list 1
\i the \l QObject class;
\i the Q_OBJECT macro inside the private section of the class
declaration;
\i the \link moc.html Meta Object Compiler (moc)\endlink. 
\endlist

The \e moc 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 the classes that
contain the Q_OBJECT macro. This generated source file is either
#included into the class' source file or compiled and linked with the
class' implementation.

In addition to providing the \link signalsandslots.html signals and
slots \endlink mechanism for communication between objects (the main
reason for introducing the system), the meta object code implements
certain other features in QObject:

\list

\i a function \link QObject::className() className() \endlink that
returns the class name as a string at runtime, without requiring
native runtime type information (RTTI) support through the C++
compiler.

\i a function \link QObject::inherits() inherits() \endlink that
returns whether an object is an instance of a class that inherits a
specified class within the QObject inheritance tree.

\i two functions \link QObject::tr() tr() \endlink and
\link QObject::trUtf8() trUtf8() \endlink for string
translation as used for internationalization.

\i two functions \link QObject::setProperty() setProperty() \endlink
and \link QObject::property() property() \endlink to dynamically set
and get \link properties.html object properties\endlink by name.

\i a function \link QObject::metaObject() metaObject() \endlink that
returns the associated \link QMetaObject meta object \endlink for the
class.

\endlist

While it is possible to use QObject as a base class without the
Q_OBJECT macro and without meta object code, neither signals and slots
nor the other features described here will be available if the
Q_OBJECT macro is not used. From the meta object system's point of
view, a QObject subclass without meta code is equivalent to its
closest ancestor with meta object code. This means for example, that
className() will not return the actual name of your class, but the
class name of this ancestor. We \e strongly recommend that all
subclasses of QObject use the Q_OBJECT macro regardless of whether
they actually use signals, slots and properties or not.

*/