|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the documentation of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 //! [0] |
|
43 Q_PROPERTY(type name |
|
44 READ getFunction |
|
45 [WRITE setFunction] |
|
46 [RESET resetFunction] |
|
47 [NOTIFY notifySignal] |
|
48 [DESIGNABLE bool] |
|
49 [SCRIPTABLE bool] |
|
50 [STORED bool] |
|
51 [USER bool] |
|
52 [CONSTANT] |
|
53 [FINAL]) |
|
54 //! [0] |
|
55 |
|
56 |
|
57 //! [1] |
|
58 Q_PROPERTY(bool focus READ hasFocus) |
|
59 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) |
|
60 Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor) |
|
61 //! [1] |
|
62 |
|
63 |
|
64 //! [2] |
|
65 Q_PROPERTY(QDate date READ getDate WRITE setDate) |
|
66 //! [2] |
|
67 |
|
68 |
|
69 //! [3] |
|
70 QPushButton *button = new QPushButton; |
|
71 QObject *object = button; |
|
72 |
|
73 button->setDown(true); |
|
74 object->setProperty("down", true); |
|
75 //! [3] |
|
76 |
|
77 |
|
78 //! [4] |
|
79 QObject *object = ... |
|
80 const QMetaObject *metaobject = object->metaObject(); |
|
81 int count = metaobject->propertyCount(); |
|
82 for (int i=0; i<count; ++i) { |
|
83 QMetaProperty metaproperty = metaobject->property(i); |
|
84 const char *name = metaproperty.name(); |
|
85 QVariant value = object->property(name); |
|
86 ... |
|
87 } |
|
88 //! [4] |
|
89 |
|
90 |
|
91 //! [5] |
|
92 class MyClass : public QObject |
|
93 { |
|
94 Q_OBJECT |
|
95 Q_PROPERTY(Priority priority READ priority WRITE setPriority) |
|
96 Q_ENUMS(Priority) |
|
97 |
|
98 public: |
|
99 MyClass(QObject *parent = 0); |
|
100 ~MyClass(); |
|
101 |
|
102 enum Priority { High, Low, VeryHigh, VeryLow }; |
|
103 |
|
104 void setPriority(Priority priority); |
|
105 Priority priority() const; |
|
106 }; |
|
107 //! [5] |
|
108 |
|
109 |
|
110 //! [6] |
|
111 MyClass *myinstance = new MyClass; |
|
112 QObject *object = myinstance; |
|
113 |
|
114 myinstance->setPriority(MyClass::VeryHigh); |
|
115 object->setProperty("priority", "VeryHigh"); |
|
116 //! [6] |
|
117 |
|
118 |
|
119 //! [7] |
|
120 Q_CLASSINFO("Version", "3.0.0") |
|
121 //! [7] |