source: trunk/doc/src/object.qdoc@ 342

Last change on this file since 342 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

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