source: trunk/doc/src/objectmodel/object.qdoc@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29 \page object.html
30 \title Object Model
31 \ingroup qt-basic-concepts
32 \brief A description of the powerful features made possible by Qt's dynamic object model.
33
34 The standard C++ object model provides very efficient runtime
35 support for the object paradigm. But its static nature is
36 inflexibile in certain problem domains. Graphical user interface
37 programming is a domain that requires both runtime efficiency and
38 a high level of flexibility. Qt provides this, by combining the
39 speed of C++ with the flexibility of the Qt Object Model.
40
41 Qt adds these features to C++:
42
43 \list
44 \o a very powerful mechanism for seamless object
45 communication called \l{signals and slots}
46 \o queryable and designable \l{Qt's Property System}{object
47 properties}
48 \o powerful \l{The Event System}{events and event filters}
49 \o contextual \l{i18n}{string translation for internationalization}
50 \o sophisticated interval driven \l timers that make it possible
51 to elegantly integrate many tasks in an event-driven GUI
52 \o hierarchical and queryable \l{Object Trees & Ownership}{object
53 trees} that organize object ownership in a natural way
54 \o guarded pointers (QPointer) that are automatically
55 set to 0 when the referenced object is destroyed, unlike normal C++
56 pointers which become dangling pointers when their objects are destroyed
57 \o a \l{metaobjects.html#qobjectcast}{dynamic cast} that works across
58 library boundaries.
59 \endlist
60
61 Many of these Qt features are implemented with standard C++
62 techniques, based on inheritance from QObject. Others, like the
63 object communication mechanism and the dynamic property system,
64 require the \l{Meta-Object System} provided
65 by Qt's own \l{moc}{Meta-Object Compiler (moc)}.
66
67 The meta-object system is a C++ extension that makes the language
68 better suited to true component GUI programming. Although
69 templates can be used to extend C++, the meta-object system
70 provides benefits using standard C++ that cannot be achieved with
71 templates; see \l{Why Doesn't Qt Use Templates for Signals and
72 Slots?}
73
74 \section1 Important Classes
75
76 These classes form the basis of the Qt Object Model.
77
78 \annotatedlist objectmodel
79
80 \target Identity vs Value
81 \section1 Qt Objects: Identity vs Value
82
83 Some of the added features listed above for the Qt Object Model,
84 require that we think of Qt Objects as identities, not values.
85 Values are copied or assigned; identities are cloned. Cloning
86 means to create a new identity, not an exact copy of the old
87 one. For example, twins have different identities. They may look
88 identical, but they have different names, different locations, and
89 may have completely different social networks.
90
91 Then cloning an identity is a more complex operation than copying
92 or assigning a value. We can see what this means in the Qt Object
93 Model.
94
95 \bold{A Qt Object...}
96
97 \list
98
99 \o might have a unique \l{QObject::objectName()}. If we copy a Qt
100 Object, what name should we give the copy?
101
102 \o has a location in an \l{Object Trees & Ownership}
103 {object hierarchy}. If we copy a Qt Object, where should the copy
104 be located?
105
106 \o can be connected to other Qt Objects to emit signals to them or
107 to receive signals emitted by them. If we copy a Qt Object, how
108 should we transfer these connections to the copy?
109
110 \o can have \l{Qt's Property System} {new properties} added to it
111 at runtime that are not declared in the C++ class. If we copy a Qt
112 Object, should the copy include the properties that were added to
113 the original?
114
115 \endlist
116
117 For these reasons, Qt Objects should be treated as identities, not
118 as values. Identities are cloned, not copied or assigned, and
119 cloning an identity is a more complex operation than copying or
120 assigning a value. Therefore, QObject and all subclasses of
121 QObject (direct or indirect) have their \l{No copy constructor}
122 {copy constructor and assignment operator} disabled.
123
124 */
Note: See TracBrowser for help on using the repository browser.