source: trunk/tools/designer/src/lib/sdk/propertysheet.qdoc@ 561

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

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 10.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 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:LGPL$
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
14** a written agreement between you and Nokia.
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** 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 have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43 \class QDesignerPropertySheetExtension
44
45 \brief The QDesignerPropertySheetExtension class allows you to
46 manipulate a widget's properties which is displayed in Qt
47 Designer's property editor.
48
49 \sa QDesignerDynamicPropertySheetExtension
50
51 \inmodule QtDesigner
52
53 QDesignerPropertySheetExtension provides a collection of functions that
54 are typically used to query a widget's properties, and to
55 manipulate the properties' appearance in the property editor. For
56 example:
57
58 \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 15
59
60 Note that if you change the value of a property using the
61 QDesignerPropertySheetExtension::setProperty() function, the undo
62 stack is not updated. To ensure that a property's value can be
63 reverted using the undo stack, you must use the
64 QDesignerFormWindowCursorInterface::setProperty() function, or its
65 buddy \l
66 {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
67 instead.
68
69 When implementing a custom widget plugin, a pointer to \QD's
70 current QDesignerFormEditorInterface object (\c formEditor in the
71 example above) is provided by the
72 QDesignerCustomWidgetInterface::initialize() function's parameter.
73
74 The property sheet, or any other extension, can be retrieved by
75 querying \QD's extension manager using the qt_extension()
76 function. When you want to release the extension, you only need to
77 delete the pointer.
78
79 All widgets have a default property sheet which populates \QD's
80 property editor with the widget's properties (i.e the ones defined
81 with the Q_PROPERTY() macro). But QDesignerPropertySheetExtension
82 also provides an interface for creating custom property sheet
83 extensions.
84
85 \warning \QD uses the QDesignerPropertySheetExtension to feed its
86 property editor. Whenever a widget is selected in its workspace,
87 \QD will query for the widget's property sheet extension. If the
88 selected widget has an implemented property sheet extension, this
89 extension will override the default property sheet.
90
91 To create a property sheet extension, your extension class must
92 inherit from both QObject and
93 QDesignerPropertySheetExtension. Then, since we are implementing
94 an interface, we must ensure that it's made known to the meta
95 object system using the Q_INTERFACES() macro:
96
97 \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 16
98
99 This enables \QD to use qobject_cast() to query for supported
100 interfaces using nothing but a QObject pointer.
101
102 In \QD the extensions are not created until they are
103 required. For that reason, when implementing a property sheet
104 extension, you must also create a QExtensionFactory, i.e a class
105 that is able to make an instance of your extension, and register
106 it using \QD's \l {QExtensionManager}{extension manager}.
107
108 When a property sheet extension is required, \QD's \l
109 {QExtensionManager}{extension manager} will run through all its
110 registered factories calling QExtensionFactory::createExtension()
111 for each until the first one that is able to create a property
112 sheet extension for the selected widget, is found. This factory
113 will then make an instance of the extension. If no such factory
114 can be found, \QD will use the default property sheet.
115
116 There are four available types of extensions in \QD:
117 QDesignerContainerExtension, QDesignerMemberSheetExtension,
118 QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt
119 Designer's behavior is the same whether the requested extension is
120 associated with a multi page container, a member sheet, a property
121 sheet or a task menu.
122
123 The QExtensionFactory class provides a standard extension factory,
124 and can also be used as an interface for custom extension
125 factories. You can either create a new QExtensionFactory and
126 reimplement the QExtensionFactory::createExtension() function. For
127 example:
128
129 \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 17
130
131 Or you can use an existing factory, expanding the
132 QExtensionFactory::createExtension() function to make the factory
133 able to create a property sheet extension extension as well. For
134 example:
135
136 \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 18
137
138 For a complete example using an extension class, see the \l
139 {designer/taskmenuextension}{Task Menu Extension example}. The
140 example shows how to create a custom widget plugin for Qt
141 Designer, and how to to use the QDesignerTaskMenuExtension class
142 to add custom items to \QD's task menu.
143
144 \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
145 Extensions}
146*/
147
148/*!
149 \fn QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension()
150
151 Destroys the property sheet extension.
152*/
153
154/*!
155 \fn int QDesignerPropertySheetExtension::count() const
156
157 Returns the selected widget's number of properties.
158*/
159
160/*!
161 \fn int QDesignerPropertySheetExtension::indexOf(const QString &name) const
162
163 Returns the index for a given property \a name.
164
165 \sa propertyName()
166*/
167
168/*!
169 \fn QString QDesignerPropertySheetExtension::propertyName(int index) const
170
171 Returns the name of the property at the given \a index.
172
173 \sa indexOf()
174*/
175
176/*!
177 \fn QString QDesignerPropertySheetExtension::propertyGroup(int index) const
178
179 Returns the property group for the property at the given \a index.
180
181 \QD's property editor supports property groups, i.e. sections of
182 related properties. A property can be related to a group using the
183 setPropertyGroup() function. The default group of any property is
184 the name of the class that defines it. For example, the
185 QObject::objectName property appears within the QObject property
186 group.
187
188 \sa indexOf(), setPropertyGroup()
189*/
190
191/*!
192 \fn void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group)
193
194 Sets the property group for the property at the given \a index to
195 \a group.
196
197 Relating a property to a group makes it appear within that group's
198 section in the property editor. The default property group of any
199 property is the name of the class that defines it. For example,
200 the QObject::objectName property appears within the QObject
201 property group.
202
203 \sa indexOf(), property(), propertyGroup()
204*/
205
206/*!
207 \fn bool QDesignerPropertySheetExtension::hasReset(int index) const
208
209 Returns true if the property at the given \a index has a reset
210 button in \QD's property editor, otherwise false.
211
212 \sa indexOf(), reset()
213*/
214
215/*!
216 \fn bool QDesignerPropertySheetExtension::reset(int index)
217
218 Resets the value of the property at the given \a index, to the
219 default value. Returns true if a default value could be found, otherwise false.
220
221 \sa indexOf(), hasReset(), isChanged()
222*/
223
224/*!
225 \fn bool QDesignerPropertySheetExtension::isVisible(int index) const
226
227 Returns true if the property at the given \a index is visible in
228 \QD's property editor, otherwise false.
229
230 \sa indexOf(), setVisible()
231*/
232
233/*!
234 \fn void QDesignerPropertySheetExtension::setVisible(int index, bool visible)
235
236 If \a visible is true, the property at the given \a index is
237 visible in \QD's property editor; otherwise the property is
238 hidden.
239
240 \sa indexOf(), isVisible()
241*/
242
243/*!
244 \fn bool QDesignerPropertySheetExtension::isAttribute(int index) const
245
246 Returns true if the property at the given \a index is an attribute,
247 which will be \e excluded from the UI file, otherwise false.
248
249 \sa indexOf(), setAttribute()
250*/
251
252/*!
253 \fn void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute)
254
255 If \a attribute is true, the property at the given \a index is
256 made an attribute which will be \e excluded from the UI file;
257 otherwise it will be included.
258
259 \sa indexOf(), isAttribute()
260*/
261
262/*!
263 \fn QVariant QDesignerPropertySheetExtension::property(int index) const
264
265 Returns the value of the property at the given \a index.
266
267 \sa indexOf(), setProperty(), propertyGroup()
268*/
269
270/*!
271 \fn void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value)
272
273 Sets the \a value of the property at the given \a index.
274
275 \warning If you change the value of a property using this
276 function, the undo stack is not updated. To ensure that a
277 property's value can be reverted using the undo stack, you must
278 use the QDesignerFormWindowCursorInterface::setProperty()
279 function, or its buddy \l
280 {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
281 instead.
282
283 \sa indexOf(), property(), propertyGroup()
284*/
285
286/*!
287 \fn bool QDesignerPropertySheetExtension::isChanged(int index) const
288
289 Returns true if the value of the property at the given \a index
290 differs from the property's default value, otherwise false.
291
292 \sa indexOf(), setChanged(), reset()
293*/
294
295/*!
296 \fn void QDesignerPropertySheetExtension::setChanged(int index, bool changed)
297
298 Sets whether the property at the given \a index is different from
299 its default value, or not, depending on the \a changed parameter.
300
301 \sa indexOf(), isChanged()
302*/
Note: See TracBrowser for help on using the repository browser.