| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 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 qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*!
|
|---|
| 43 | \module QtDesigner
|
|---|
| 44 | \title QtDesigner Module
|
|---|
| 45 | \contentspage Qt's Modules
|
|---|
| 46 | \previouspage Qt3Support
|
|---|
| 47 | \nextpage QtUiTools
|
|---|
| 48 | \ingroup modules
|
|---|
| 49 |
|
|---|
| 50 | \brief The QtDesigner module provides classes that allow you to
|
|---|
| 51 | create your own custom widget plugins for Qt Designer, and classes
|
|---|
| 52 | that enable you to access Qt Designer's components.
|
|---|
| 53 |
|
|---|
| 54 | In addition, the QFormBuilder class provides the possibility of
|
|---|
| 55 | constructing user interfaces from \c .ui files at run-time.
|
|---|
| 56 |
|
|---|
| 57 | To include the definitions of the module's classes, use the
|
|---|
| 58 | following directive:
|
|---|
| 59 |
|
|---|
| 60 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 0
|
|---|
| 61 |
|
|---|
| 62 | To link against the module, add this line to your \c qmake .pro
|
|---|
| 63 | file:
|
|---|
| 64 |
|
|---|
| 65 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 1
|
|---|
| 66 |
|
|---|
| 67 | \note These classes are part of the \l{Open Source Versions of Qt} and
|
|---|
| 68 | \l{Qt Commercial Editions}{Qt Full Framework Edition} for commercial
|
|---|
| 69 | users.
|
|---|
| 70 |
|
|---|
| 71 | \tableofcontents
|
|---|
| 72 |
|
|---|
| 73 | \section1 Creating Custom Widget Plugins
|
|---|
| 74 |
|
|---|
| 75 | When implementing a custom widget plugin for \QD, you must
|
|---|
| 76 | subclass QDesignerCustomWidgetInterface to expose your custom
|
|---|
| 77 | widget to \QD. A single custom widget plugin is built as a
|
|---|
| 78 | separate library. If you want to include several custom widget
|
|---|
| 79 | plugins in the same library, you must in addition subclass
|
|---|
| 80 | QDesignerCustomWidgetCollectionInterface.
|
|---|
| 81 |
|
|---|
| 82 | To provide your custom widget plugin with the expected behavior
|
|---|
| 83 | and functionality within \QD's workspace you can subclass the
|
|---|
| 84 | associated extension classes:
|
|---|
| 85 |
|
|---|
| 86 | The QDesignerContainerExtension class allows you to add pages to a
|
|---|
| 87 | custom multi-page container. The QDesignerTaskMenuExtension class
|
|---|
| 88 | allows you to add custom menu entries to \QD's task menu. The
|
|---|
| 89 | QDesignerMemberSheetExtension class allows you to manipulate a
|
|---|
| 90 | widget's member functions which is displayed when configuring
|
|---|
| 91 | connections using \QD's mode for editing signals and slots. And
|
|---|
| 92 | finally, the QDesignerPropertySheetExtension class allows you to
|
|---|
| 93 | manipulate a widget's properties which is displayed in \QD's
|
|---|
| 94 | property editor.
|
|---|
| 95 |
|
|---|
| 96 | \image qtdesignerextensions.png
|
|---|
| 97 |
|
|---|
| 98 | In \QD the extensions are not created until they are required. For
|
|---|
| 99 | that reason, when implementing extensions, you must also subclass
|
|---|
| 100 | QExtensionFactory, i.e create a class that is able to make
|
|---|
| 101 | instances of your extensions. In addition, you must make \QD's
|
|---|
| 102 | extension manager register your factory; the extension manager
|
|---|
| 103 | controls the construction of extensions as they are required, and
|
|---|
| 104 | you can access it through QDesignerFormEditorInterface and
|
|---|
| 105 | QExtensionManager.
|
|---|
| 106 |
|
|---|
| 107 | For a complete example creating a custom widget plugin with an
|
|---|
| 108 | extension, see the \l {designer/taskmenuextension}{Task Menu
|
|---|
| 109 | Extension} or \l {designer/containerextension}{Container
|
|---|
| 110 | Extension} examples.
|
|---|
| 111 |
|
|---|
| 112 | \section1 Retrieving Access to \QD Components
|
|---|
| 113 |
|
|---|
| 114 | The purpose of the classes mentioned in this section is to provide
|
|---|
| 115 | access to \QD's components, managers and workspace, and they are
|
|---|
| 116 | not intended to be instantiated directly.
|
|---|
| 117 |
|
|---|
| 118 | \QD is composed by several components. It has an action editor, a
|
|---|
| 119 | property editor, widget box and object inspector which you can
|
|---|
| 120 | view in its workspace.
|
|---|
| 121 |
|
|---|
| 122 | \image qtdesignerscreenshot.png
|
|---|
| 123 |
|
|---|
| 124 | \QD also has an object that works behind the scene; it contains
|
|---|
| 125 | the logic that integrates all of \QD's components into a coherent
|
|---|
| 126 | application. You can access this object, using the
|
|---|
| 127 | QDesignerFormEditorInterface, to retrieve interfaces to \QD's
|
|---|
| 128 | components:
|
|---|
| 129 |
|
|---|
| 130 | \list
|
|---|
| 131 | \o QDesignerActionEditorInterface
|
|---|
| 132 | \o QDesignerObjectInspectorInterface
|
|---|
| 133 | \o QDesignerPropertyEditorInterface
|
|---|
| 134 | \o QDesignerWidgetBoxInterface
|
|---|
| 135 | \endlist
|
|---|
| 136 |
|
|---|
| 137 | In addition, you can use QDesignerFormEditorInterface to retrieve
|
|---|
| 138 | interfaces to \QD's extension manager (QExtensionManager) and form
|
|---|
| 139 | window manager (QDesignerFormWindowManagerInterface). The
|
|---|
| 140 | extension manager controls the construction of extensions as they
|
|---|
| 141 | are required, while the form window manager controls the form
|
|---|
| 142 | windows appearing in \QD's workspace.
|
|---|
| 143 |
|
|---|
| 144 | Once you have an interface to \QD's form window manager
|
|---|
| 145 | (QDesignerFormWindowManagerInterface), you also have access to all
|
|---|
| 146 | the form windows currently appearing in \QD's workspace: The
|
|---|
| 147 | QDesignerFormWindowInterface class allows you to query and
|
|---|
| 148 | manipulate the form windows, and it provides an interface to the
|
|---|
| 149 | form windows' cursors. QDesignerFormWindowCursorInterface is a
|
|---|
| 150 | convenience class allowing you to query and modify a given form
|
|---|
| 151 | window's widget selection, and in addition modify the properties
|
|---|
| 152 | of all the form's widgets.
|
|---|
| 153 |
|
|---|
| 154 | \section1 Creating User Interfaces at Run-Time
|
|---|
| 155 |
|
|---|
| 156 | The \c QtDesigner module contains the QFormBuilder class that
|
|---|
| 157 | provides a mechanism for dynamically creating user interfaces at
|
|---|
| 158 | run-time, based on \c .ui files created with \QD. This class is
|
|---|
| 159 | typically used by custom components and applications that embed
|
|---|
| 160 | \QD. Standalone applications that need to dynamically generate
|
|---|
| 161 | user interfaces at run-time use the QUiLoader class, found in
|
|---|
| 162 | the QtUiTools module.
|
|---|
| 163 |
|
|---|
| 164 | For a complete example using QUiLoader, see
|
|---|
| 165 | the \l {designer/calculatorbuilder}{Calculator Builder example}.
|
|---|
| 166 |
|
|---|
| 167 | \sa {Qt Designer Manual}, {QtUiTools Module}
|
|---|
| 168 | */
|
|---|
| 169 |
|
|---|
| 170 | /*!
|
|---|
| 171 | \class QDesignerMemberSheetExtension
|
|---|
| 172 |
|
|---|
| 173 | \brief The QDesignerMemberSheetExtension class allows you to
|
|---|
| 174 | manipulate a widget's member functions which is displayed when
|
|---|
| 175 | configuring connections using Qt Designer's mode for editing
|
|---|
| 176 | signals and slots.
|
|---|
| 177 |
|
|---|
| 178 | \inmodule QtDesigner
|
|---|
| 179 |
|
|---|
| 180 | QDesignerMemberSheetExtension is a collection of functions that is
|
|---|
| 181 | typically used to query a widget's member functions, and to
|
|---|
| 182 | manipulate the member functions' appearance in \QD's signals and
|
|---|
| 183 | slots editing mode. For example:
|
|---|
| 184 |
|
|---|
| 185 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 2
|
|---|
| 186 |
|
|---|
| 187 | When implementing a custom widget plugin, a pointer to \QD's
|
|---|
| 188 | current QDesignerFormEditorInterface object (\c formEditor in the
|
|---|
| 189 | example above) is provided by the
|
|---|
| 190 | QDesignerCustomWidgetInterface::initialize() function's parameter.
|
|---|
| 191 |
|
|---|
| 192 | The member sheet (and any other extension), can be retrieved by
|
|---|
| 193 | querying \QD's extension manager using the qt_extension()
|
|---|
| 194 | function. When you want to release the extension, you only need to
|
|---|
| 195 | delete the pointer.
|
|---|
| 196 |
|
|---|
| 197 | All widgets have a default member sheet used in \QD's signals and
|
|---|
| 198 | slots editing mode with the widget's member functions. But
|
|---|
| 199 | QDesignerMemberSheetExtension also provides an interface for
|
|---|
| 200 | creating custom member sheet extensions.
|
|---|
| 201 |
|
|---|
| 202 | \warning \QD uses the QDesignerMemberSheetExtension to facilitate
|
|---|
| 203 | the signal and slot editing mode. Whenever a connection between
|
|---|
| 204 | two widgets is requested, \QD will query for the widgets' member
|
|---|
| 205 | sheet extensions. If a widget has an implemented member sheet
|
|---|
| 206 | extension, this extension will override the default member sheet.
|
|---|
| 207 |
|
|---|
| 208 | To create a member sheet extension, your extension class must
|
|---|
| 209 | inherit from both QObject and QDesignerMemberSheetExtension. Then,
|
|---|
| 210 | since we are implementing an interface, we must ensure that it's
|
|---|
| 211 | made known to the meta object system using the Q_INTERFACES()
|
|---|
| 212 | macro:
|
|---|
| 213 |
|
|---|
| 214 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 3
|
|---|
| 215 |
|
|---|
| 216 | This enables \QD to use qobject_cast() to query for
|
|---|
| 217 | supported interfaces using nothing but a QObject pointer.
|
|---|
| 218 |
|
|---|
| 219 | In \QD the extensions are not created until they are
|
|---|
| 220 | required. For that reason, when implementing a member sheet
|
|---|
| 221 | extension, you must also create a QExtensionFactory, i.e a class
|
|---|
| 222 | that is able to make an instance of your extension, and register
|
|---|
| 223 | it using \QD's \l {QExtensionManager}{extension manager}.
|
|---|
| 224 |
|
|---|
| 225 | When a widget's member sheet extension is required, \QD's \l
|
|---|
| 226 | {QExtensionManager}{extension manager} will run through all its
|
|---|
| 227 | registered factories calling QExtensionFactory::createExtension()
|
|---|
| 228 | for each until the first one that is able to create a member sheet
|
|---|
| 229 | extension for that widget, is found. This factory will then make
|
|---|
| 230 | an instance of the extension. If no such factory is found, \QD
|
|---|
| 231 | will use the default member sheet.
|
|---|
| 232 |
|
|---|
| 233 | There are four available types of extensions in \QD:
|
|---|
| 234 | QDesignerContainerExtension, QDesignerMemberSheetExtension,
|
|---|
| 235 | QDesignerPropertySheetExtension and
|
|---|
| 236 | QDesignerTaskMenuExtension. \QD's behavior is the same whether the
|
|---|
| 237 | requested extension is associated with a multi page container, a
|
|---|
| 238 | member sheet, a property sheet or a task menu.
|
|---|
| 239 |
|
|---|
| 240 | The QExtensionFactory class provides a standard extension
|
|---|
| 241 | factory, and can also be used as an interface for custom
|
|---|
| 242 | extension factories. You can either create a new
|
|---|
| 243 | QExtensionFactory and reimplement the
|
|---|
| 244 | QExtensionFactory::createExtension() function. For example:
|
|---|
| 245 |
|
|---|
| 246 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 4
|
|---|
| 247 |
|
|---|
| 248 | Or you can use an existing factory, expanding the
|
|---|
| 249 | QExtensionFactory::createExtension() function to make the factory
|
|---|
| 250 | able to create a member sheet extension as well. For example:
|
|---|
| 251 |
|
|---|
| 252 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 5
|
|---|
| 253 |
|
|---|
| 254 | For a complete example using an extension class, see \l
|
|---|
| 255 | {designer/taskmenuextension}{Task Menu Extension example}. The
|
|---|
| 256 | example shows how to create a custom widget plugin for Qt
|
|---|
| 257 | Designer, and how to to use the QDesignerTaskMenuExtension class
|
|---|
| 258 | to add custom items to \QD's task menu.
|
|---|
| 259 |
|
|---|
| 260 | \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
|
|---|
| 261 | Extensions}
|
|---|
| 262 | */
|
|---|
| 263 |
|
|---|
| 264 | /*!
|
|---|
| 265 | \fn QDesignerMemberSheetExtension::~QDesignerMemberSheetExtension()
|
|---|
| 266 |
|
|---|
| 267 | Destroys the member sheet extension.
|
|---|
| 268 | */
|
|---|
| 269 |
|
|---|
| 270 | /*!
|
|---|
| 271 | \fn int QDesignerMemberSheetExtension::count() const
|
|---|
| 272 |
|
|---|
| 273 | Returns the extension's number of member functions.
|
|---|
| 274 | */
|
|---|
| 275 |
|
|---|
| 276 | /*!
|
|---|
| 277 | \fn int QDesignerMemberSheetExtension::indexOf(const QString &name) const
|
|---|
| 278 |
|
|---|
| 279 | Returns the index of the member function specified by the given \a
|
|---|
| 280 | name.
|
|---|
| 281 |
|
|---|
| 282 | \sa memberName()
|
|---|
| 283 | */
|
|---|
| 284 |
|
|---|
| 285 | /*!
|
|---|
| 286 | \fn QString QDesignerMemberSheetExtension::memberName(int index) const
|
|---|
| 287 |
|
|---|
| 288 | Returns the name of the member function with the given \a index.
|
|---|
| 289 |
|
|---|
| 290 | \sa indexOf()
|
|---|
| 291 | */
|
|---|
| 292 |
|
|---|
| 293 | /*!
|
|---|
| 294 | \fn QString QDesignerMemberSheetExtension::memberGroup(int index) const
|
|---|
| 295 |
|
|---|
| 296 | Returns the name of the member group specified for the function
|
|---|
| 297 | with the given \a index.
|
|---|
| 298 |
|
|---|
| 299 | \sa indexOf(), setMemberGroup()
|
|---|
| 300 | */
|
|---|
| 301 |
|
|---|
| 302 | /*!
|
|---|
| 303 | \fn void QDesignerMemberSheetExtension::setMemberGroup(int index, const QString &group)
|
|---|
| 304 |
|
|---|
| 305 | Sets the member group of the member function with the given \a
|
|---|
| 306 | index, to \a group.
|
|---|
| 307 |
|
|---|
| 308 | \sa indexOf(), memberGroup()
|
|---|
| 309 | */
|
|---|
| 310 |
|
|---|
| 311 | /*!
|
|---|
| 312 | \fn bool QDesignerMemberSheetExtension::isVisible(int index) const
|
|---|
| 313 |
|
|---|
| 314 | Returns true if the member function with the given \a index is
|
|---|
| 315 | visible in \QD's signal and slot editor, otherwise false.
|
|---|
| 316 |
|
|---|
| 317 | \sa indexOf(), setVisible()
|
|---|
| 318 | */
|
|---|
| 319 |
|
|---|
| 320 | /*!
|
|---|
| 321 | \fn void QDesignerMemberSheetExtension::setVisible(int index, bool visible)
|
|---|
| 322 |
|
|---|
| 323 | If \a visible is true, the member function with the given \a index
|
|---|
| 324 | is visible in \QD's signals and slots editing mode; otherwise the
|
|---|
| 325 | member function is hidden.
|
|---|
| 326 |
|
|---|
| 327 | \sa indexOf(), isVisible()
|
|---|
| 328 | */
|
|---|
| 329 |
|
|---|
| 330 | /*!
|
|---|
| 331 | \fn virtual bool QDesignerMemberSheetExtension::isSignal(int index) const
|
|---|
| 332 |
|
|---|
| 333 | Returns true if the member function with the given \a index is a
|
|---|
| 334 | signal, otherwise false.
|
|---|
| 335 |
|
|---|
| 336 | \sa indexOf()
|
|---|
| 337 | */
|
|---|
| 338 |
|
|---|
| 339 | /*!
|
|---|
| 340 | \fn bool QDesignerMemberSheetExtension::isSlot(int index) const
|
|---|
| 341 |
|
|---|
| 342 | Returns true if the member function with the given \a index is a
|
|---|
| 343 | slot, otherwise false.
|
|---|
| 344 |
|
|---|
| 345 | \sa indexOf()
|
|---|
| 346 | */
|
|---|
| 347 |
|
|---|
| 348 | /*!
|
|---|
| 349 | \fn bool QDesignerMemberSheetExtension::inheritedFromWidget(int index) const
|
|---|
| 350 |
|
|---|
| 351 | Returns true if the member function with the given \a index is
|
|---|
| 352 | inherited from QWidget, otherwise false.
|
|---|
| 353 |
|
|---|
| 354 | \sa indexOf()
|
|---|
| 355 | */
|
|---|
| 356 |
|
|---|
| 357 | /*!
|
|---|
| 358 | \fn QString QDesignerMemberSheetExtension::declaredInClass(int index) const
|
|---|
| 359 |
|
|---|
| 360 | Returns the name of the class in which the member function with
|
|---|
| 361 | the given \a index is declared.
|
|---|
| 362 |
|
|---|
| 363 | \sa indexOf()
|
|---|
| 364 | */
|
|---|
| 365 |
|
|---|
| 366 | /*!
|
|---|
| 367 | \fn QString QDesignerMemberSheetExtension::signature(int index) const
|
|---|
| 368 |
|
|---|
| 369 | Returns the signature of the member function with the given \a
|
|---|
| 370 | index.
|
|---|
| 371 |
|
|---|
| 372 | \sa indexOf()
|
|---|
| 373 | */
|
|---|
| 374 |
|
|---|
| 375 | /*!
|
|---|
| 376 | \fn QList<QByteArray> QDesignerMemberSheetExtension::parameterTypes(int index) const
|
|---|
| 377 |
|
|---|
| 378 | Returns the parameter types of the member function with the given
|
|---|
| 379 | \a index, as a QByteArray list.
|
|---|
| 380 |
|
|---|
| 381 | \sa indexOf(), parameterNames()
|
|---|
| 382 | */
|
|---|
| 383 |
|
|---|
| 384 | /*!
|
|---|
| 385 | \fn QList<QByteArray> QDesignerMemberSheetExtension::parameterNames(int index) const
|
|---|
| 386 |
|
|---|
| 387 | Returns the parameter names of the member function with the given
|
|---|
| 388 | \a index, as a QByteArray list.
|
|---|
| 389 |
|
|---|
| 390 | \sa indexOf(), parameterTypes()
|
|---|
| 391 | */
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 | // Doc: Interface only
|
|---|
| 395 |
|
|---|
| 396 | /*!
|
|---|
| 397 | \class QDesignerLayoutDecorationExtension
|
|---|
| 398 | \brief The QDesignerLayoutDecorationExtension class provides an extension to a layout in \QD.
|
|---|
| 399 | \inmodule QtDesigner
|
|---|
| 400 | \internal
|
|---|
| 401 | */
|
|---|
| 402 |
|
|---|
| 403 | /*!
|
|---|
| 404 | \enum QDesignerLayoutDecorationExtension::InsertMode
|
|---|
| 405 |
|
|---|
| 406 | This enum describes the modes that are used to insert items into a layout.
|
|---|
| 407 |
|
|---|
| 408 | \value InsertWidgetMode Widgets are inserted into empty cells in a layout.
|
|---|
| 409 | \value InsertRowMode Whole rows are inserted into a vertical or grid layout.
|
|---|
| 410 | \value InsertColumnMode Whole columns are inserted into a horizontal or grid layout.
|
|---|
| 411 | */
|
|---|
| 412 |
|
|---|
| 413 | /*!
|
|---|
| 414 | \fn virtual QDesignerLayoutDecorationExtension::~QDesignerLayoutDecorationExtension()
|
|---|
| 415 |
|
|---|
| 416 | Destroys the extension.
|
|---|
| 417 | */
|
|---|
| 418 |
|
|---|
| 419 | /*!
|
|---|
| 420 | \fn virtual QList<QWidget*> QDesignerLayoutDecorationExtension::widgets(QLayout *layout) const
|
|---|
| 421 |
|
|---|
| 422 | Returns the widgets that are managed by the given \a layout.
|
|---|
| 423 |
|
|---|
| 424 | \sa insertWidget(), removeWidget()
|
|---|
| 425 | */
|
|---|
| 426 |
|
|---|
| 427 | /*!
|
|---|
| 428 | \fn QRect QDesignerLayoutDecorationExtension::itemInfo(int index) const
|
|---|
| 429 |
|
|---|
| 430 | Returns the rectangle covered by the item at the given \a index in the layout.
|
|---|
| 431 | */
|
|---|
| 432 |
|
|---|
| 433 | /*!
|
|---|
| 434 | \fn int QDesignerLayoutDecorationExtension::indexOf(QWidget *widget) const
|
|---|
| 435 |
|
|---|
| 436 | Returns the index of the specified \a widget in the layout.
|
|---|
| 437 | */
|
|---|
| 438 |
|
|---|
| 439 | /*!
|
|---|
| 440 | \fn int QDesignerLayoutDecorationExtension::indexOf(QLayoutItem *item) const
|
|---|
| 441 |
|
|---|
| 442 | Returns the index of the specified layout \a item.
|
|---|
| 443 | */
|
|---|
| 444 |
|
|---|
| 445 | /*!
|
|---|
| 446 | \fn QDesignerLayoutDecorationExtension::InsertMode QDesignerLayoutDecorationExtension::currentInsertMode() const
|
|---|
| 447 |
|
|---|
| 448 | Returns the current insertion mode.
|
|---|
| 449 | */
|
|---|
| 450 |
|
|---|
| 451 | /*!
|
|---|
| 452 | \fn int QDesignerLayoutDecorationExtension::currentIndex() const
|
|---|
| 453 |
|
|---|
| 454 | Returns the current index in the layout.
|
|---|
| 455 | */
|
|---|
| 456 |
|
|---|
| 457 | /*!
|
|---|
| 458 | \fn QPair<int, int> QDesignerLayoutDecorationExtension::currentCell() const
|
|---|
| 459 |
|
|---|
| 460 | Returns a pair containing the row and column of the current cell in the layout.
|
|---|
| 461 | */
|
|---|
| 462 |
|
|---|
| 463 | /*!
|
|---|
| 464 | \fn void QDesignerLayoutDecorationExtension::insertWidget(QWidget *widget, const QPair<int, int> &cell)
|
|---|
| 465 |
|
|---|
| 466 | Inserts the given \a widget into the specified \a cell in the layout.
|
|---|
| 467 |
|
|---|
| 468 | \sa removeWidget()
|
|---|
| 469 | */
|
|---|
| 470 |
|
|---|
| 471 | /*!
|
|---|
| 472 | \fn void QDesignerLayoutDecorationExtension::removeWidget(QWidget *widget)
|
|---|
| 473 |
|
|---|
| 474 | Removes the specified \a widget from the layout.
|
|---|
| 475 |
|
|---|
| 476 | \sa insertWidget()
|
|---|
| 477 | */
|
|---|
| 478 |
|
|---|
| 479 | /*!
|
|---|
| 480 | \fn void QDesignerLayoutDecorationExtension::insertRow(int row)
|
|---|
| 481 |
|
|---|
| 482 | Inserts a new row into the form at the position specified by \a row.
|
|---|
| 483 | */
|
|---|
| 484 |
|
|---|
| 485 | /*!
|
|---|
| 486 | \fn void QDesignerLayoutDecorationExtension::insertColumn(int column)
|
|---|
| 487 |
|
|---|
| 488 | Inserts a new column into the form at the position specified by \a column.
|
|---|
| 489 | */
|
|---|
| 490 |
|
|---|
| 491 | /*!
|
|---|
| 492 | \fn void QDesignerLayoutDecorationExtension::simplify()
|
|---|
| 493 |
|
|---|
| 494 | Simplifies the layout by removing unnecessary empty rows and columns, and by changing the
|
|---|
| 495 | number of rows or columns spanned by widgets.
|
|---|
| 496 | */
|
|---|
| 497 |
|
|---|
| 498 | /*!
|
|---|
| 499 | \fn int QDesignerLayoutDecorationExtension::findItemAt(const QPoint &position) const
|
|---|
| 500 |
|
|---|
| 501 | Returns the index of the item in the layout that covers the given \a position.
|
|---|
| 502 | */
|
|---|
| 503 |
|
|---|
| 504 | /*!
|
|---|
| 505 | \fn int QDesignerLayoutDecorationExtension::findItemAt(int row, int column) const
|
|---|
| 506 |
|
|---|
| 507 | Returns the item in the layout that occupies the specified \a row and \a column in the layout.
|
|---|
| 508 |
|
|---|
| 509 | Currently, this only applies to grid layouts.
|
|---|
| 510 | */
|
|---|
| 511 |
|
|---|
| 512 | /*!
|
|---|
| 513 | \fn void QDesignerLayoutDecorationExtension::adjustIndicator(const QPoint &position, int index)
|
|---|
| 514 |
|
|---|
| 515 | Adjusts the indicator for the item specified by \a index so that
|
|---|
| 516 | it lies at the given \a position on the form.
|
|---|
| 517 | */
|
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 | // Doc: Interface only
|
|---|
| 521 |
|
|---|
| 522 | /*!
|
|---|
| 523 | \class QDesignerContainerExtension
|
|---|
| 524 | \brief The QDesignerContainerExtension class allows you to add pages to
|
|---|
| 525 | a custom multi-page container in Qt Designer's workspace.
|
|---|
| 526 | \inmodule QtDesigner
|
|---|
| 527 |
|
|---|
| 528 | QDesignerContainerExtension provide an interface for creating
|
|---|
| 529 | custom container extensions. A container extension consists of a
|
|---|
| 530 | collection of functions that \QD needs to manage a multi-page
|
|---|
| 531 | container plugin, and a list of the container's pages.
|
|---|
| 532 |
|
|---|
| 533 | \image containerextension-example.png
|
|---|
| 534 |
|
|---|
| 535 | \warning This is \e not an extension for container plugins in
|
|---|
| 536 | general, only custom \e multi-page containers.
|
|---|
| 537 |
|
|---|
| 538 | To create a container extension, your extension class must inherit
|
|---|
| 539 | from both QObject and QDesignerContainerExtension. For example:
|
|---|
| 540 |
|
|---|
| 541 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 6
|
|---|
| 542 |
|
|---|
| 543 | Since we are implementing an interface, we must ensure that it's
|
|---|
| 544 | made known to the meta object system using the Q_INTERFACES()
|
|---|
| 545 | macro. This enables \QD to use the qobject_cast() function to
|
|---|
| 546 | query for supported interfaces using nothing but a QObject
|
|---|
| 547 | pointer.
|
|---|
| 548 |
|
|---|
| 549 | You must reimplement several functions to enable \QD to manage a
|
|---|
| 550 | custom multi-page container widget: \QD uses count() to keep track
|
|---|
| 551 | of the number pages in your container, widget() to return the page
|
|---|
| 552 | at a given index in the list of the container's pages, and
|
|---|
| 553 | currentIndex() to return the list index of the selected page. \QD
|
|---|
| 554 | uses the addWidget() function to add a given page to the
|
|---|
| 555 | container, expecting it to be appended to the list of pages, while
|
|---|
| 556 | it expects the insertWidget() function to add a given page to the
|
|---|
| 557 | container by inserting it at a given index.
|
|---|
| 558 |
|
|---|
| 559 | In \QD the extensions are not created until they are
|
|---|
| 560 | required. For that reason you must also create a
|
|---|
| 561 | QExtensionFactory, i.e a class that is able to make an instance of
|
|---|
| 562 | your extension, and register it using \QD's \l
|
|---|
| 563 | {QExtensionManager}{extension manager}.
|
|---|
| 564 |
|
|---|
| 565 | When a container extension is required, \QD's \l
|
|---|
| 566 | {QExtensionManager}{extension manager} will run through all its
|
|---|
| 567 | registered factories calling QExtensionFactory::createExtension()
|
|---|
| 568 | for each until the first one that is able to create a container
|
|---|
| 569 | extension, is found. This factory will then create the extension
|
|---|
| 570 | for the plugin.
|
|---|
| 571 |
|
|---|
| 572 | There are four available types of extensions in \QD:
|
|---|
| 573 | QDesignerContainerExtension , QDesignerMemberSheetExtension,
|
|---|
| 574 | QDesignerPropertySheetExtension and QDesignerTaskMenuExtension.
|
|---|
| 575 | \QD's behavior is the same whether the requested extension is
|
|---|
| 576 | associated with a multi page container, a member sheet, a property
|
|---|
| 577 | sheet or a task menu.
|
|---|
| 578 |
|
|---|
| 579 | The QExtensionFactory class provides a standard extension factory,
|
|---|
| 580 | and can also be used as an interface for custom extension
|
|---|
| 581 | factories. You can either create a new QExtensionFactory and
|
|---|
| 582 | reimplement the QExtensionFactory::createExtension() function. For
|
|---|
| 583 | example:
|
|---|
| 584 |
|
|---|
| 585 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 7
|
|---|
| 586 |
|
|---|
| 587 | Or you can use an existing factory, expanding the
|
|---|
| 588 | QExtensionFactory::createExtension() function to make the factory
|
|---|
| 589 | able to create a container extension as well. For example:
|
|---|
| 590 |
|
|---|
| 591 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 8
|
|---|
| 592 |
|
|---|
| 593 | For a complete example using the QDesignerContainerExtension
|
|---|
| 594 | class, see the \l {designer/containerextension}{Container
|
|---|
| 595 | Extension example}. The example shows how to create a custom
|
|---|
| 596 | multi-page plugin for \QD.
|
|---|
| 597 |
|
|---|
| 598 | \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
|
|---|
| 599 | Extensions}
|
|---|
| 600 | */
|
|---|
| 601 |
|
|---|
| 602 | /*!
|
|---|
| 603 | \fn QDesignerContainerExtension::~QDesignerContainerExtension()
|
|---|
| 604 |
|
|---|
| 605 | Destroys the extension.
|
|---|
| 606 | */
|
|---|
| 607 |
|
|---|
| 608 | /*!
|
|---|
| 609 | \fn int QDesignerContainerExtension::count() const
|
|---|
| 610 |
|
|---|
| 611 | Returns the number of pages in the container.
|
|---|
| 612 | */
|
|---|
| 613 |
|
|---|
| 614 | /*!
|
|---|
| 615 | \fn QWidget *QDesignerContainerExtension::widget(int index) const
|
|---|
| 616 |
|
|---|
| 617 | Returns the page at the given \a index in the extension's list of
|
|---|
| 618 | pages.
|
|---|
| 619 |
|
|---|
| 620 | \sa addWidget(), insertWidget()
|
|---|
| 621 | */
|
|---|
| 622 |
|
|---|
| 623 | /*!
|
|---|
| 624 | \fn int QDesignerContainerExtension::currentIndex() const
|
|---|
| 625 |
|
|---|
| 626 | Returns the index of the currently selected page in the
|
|---|
| 627 | container.
|
|---|
| 628 |
|
|---|
| 629 | \sa setCurrentIndex()
|
|---|
| 630 | */
|
|---|
| 631 |
|
|---|
| 632 | /*!
|
|---|
| 633 | \fn void QDesignerContainerExtension::setCurrentIndex(int index)
|
|---|
| 634 |
|
|---|
| 635 | Sets the the currently selected page in the container to be the
|
|---|
| 636 | page at the given \a index in the extension's list of pages.
|
|---|
| 637 |
|
|---|
| 638 | \sa currentIndex()
|
|---|
| 639 | */
|
|---|
| 640 |
|
|---|
| 641 | /*!
|
|---|
| 642 | \fn void QDesignerContainerExtension::addWidget(QWidget *page)
|
|---|
| 643 |
|
|---|
| 644 | Adds the given \a page to the container by appending it to the
|
|---|
| 645 | extension's list of pages.
|
|---|
| 646 |
|
|---|
| 647 | \sa insertWidget(), remove(), widget()
|
|---|
| 648 | */
|
|---|
| 649 |
|
|---|
| 650 | /*!
|
|---|
| 651 | \fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page)
|
|---|
| 652 |
|
|---|
| 653 | Adds the given \a page to the container by inserting it at the
|
|---|
| 654 | given \a index in the extension's list of pages.
|
|---|
| 655 |
|
|---|
| 656 | \sa addWidget(), remove(), widget()
|
|---|
| 657 | */
|
|---|
| 658 |
|
|---|
| 659 | /*!
|
|---|
| 660 | \fn void QDesignerContainerExtension::remove(int index)
|
|---|
| 661 |
|
|---|
| 662 | Removes the page at the given \a index from the extension's list
|
|---|
| 663 | of pages.
|
|---|
| 664 |
|
|---|
| 665 | \sa addWidget(), insertWidget()
|
|---|
| 666 | */
|
|---|
| 667 |
|
|---|
| 668 |
|
|---|
| 669 | // Doc: Interface only
|
|---|
| 670 |
|
|---|
| 671 | /*!
|
|---|
| 672 | \class QDesignerTaskMenuExtension
|
|---|
| 673 | \brief The QDesignerTaskMenuExtension class allows you to add custom
|
|---|
| 674 | menu entries to Qt Designer's task menu.
|
|---|
| 675 | \inmodule QtDesigner
|
|---|
| 676 |
|
|---|
| 677 | QDesignerTaskMenuExtension provides an interface for creating
|
|---|
| 678 | custom task menu extensions. It is typically used to create task
|
|---|
| 679 | menu entries that are specific to a plugin in \QD.
|
|---|
| 680 |
|
|---|
| 681 | \QD uses the QDesignerTaskMenuExtension to feed its task
|
|---|
| 682 | menu. Whenever a task menu is requested, \QD will query
|
|---|
| 683 | for the selected widget's task menu extension.
|
|---|
| 684 |
|
|---|
| 685 | \image taskmenuextension-example-faded.png
|
|---|
| 686 |
|
|---|
| 687 | A task menu extension is a collection of QActions. The actions
|
|---|
| 688 | appear as entries in the task menu when the plugin with the
|
|---|
| 689 | specified extension is selected. The image above shows the custom
|
|---|
| 690 | \gui {Edit State...} action which appears in addition to \QD's
|
|---|
| 691 | default task menu entries: \gui Cut, \gui Copy, \gui Paste etc.
|
|---|
| 692 |
|
|---|
| 693 | To create a custom task menu extension, your extension class must
|
|---|
| 694 | inherit from both QObject and QDesignerTaskMenuExtension. For
|
|---|
| 695 | example:
|
|---|
| 696 |
|
|---|
| 697 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 9
|
|---|
| 698 |
|
|---|
| 699 | Since we are implementing an interface, we must ensure that it
|
|---|
| 700 | is made known to the meta-object system using the Q_INTERFACES()
|
|---|
| 701 | macro. This enables \QD to use the qobject_cast() function to
|
|---|
| 702 | query for supported interfaces using nothing but a QObject
|
|---|
| 703 | pointer.
|
|---|
| 704 |
|
|---|
| 705 | You must reimplement the taskActions() function to return a list
|
|---|
| 706 | of actions that will be included in \QD task menu. Optionally, you
|
|---|
| 707 | can reimplement the preferredEditAction() function to set the
|
|---|
| 708 | action that is invoked when selecting your plugin and pressing
|
|---|
| 709 | \key F2. The preferred edit action must be one of the actions
|
|---|
| 710 | returned by taskActions() and, if it's not defined, pressing the
|
|---|
| 711 | \key F2 key will simply be ignored.
|
|---|
| 712 |
|
|---|
| 713 | In \QD, extensions are not created until they are required. A
|
|---|
| 714 | task menu extension, for example, is created when you click the
|
|---|
| 715 | right mouse button over a widget in \QD's workspace. For that
|
|---|
| 716 | reason you must also construct an extension factory, using either
|
|---|
| 717 | QExtensionFactory or a subclass, and register it using \QD's
|
|---|
| 718 | \l {QExtensionManager}{extension manager}.
|
|---|
| 719 |
|
|---|
| 720 | When a task menu extension is required, \QD's \l
|
|---|
| 721 | {QExtensionManager}{extension manager} will run through all its
|
|---|
| 722 | registered factories calling QExtensionFactory::createExtension()
|
|---|
| 723 | for each until it finds one that is able to create a task menu
|
|---|
| 724 | extension for the selected widget. This factory will then make an
|
|---|
| 725 | instance of the extension.
|
|---|
| 726 |
|
|---|
| 727 | There are four available types of extensions in \QD:
|
|---|
| 728 | QDesignerContainerExtension, QDesignerMemberSheetExtension,
|
|---|
| 729 | QDesignerPropertySheetExtension, and QDesignerTaskMenuExtension.
|
|---|
| 730 | \QD's behavior is the same whether the requested extension is
|
|---|
| 731 | associated with a container, a member sheet, a property sheet or a
|
|---|
| 732 | task menu.
|
|---|
| 733 |
|
|---|
| 734 | The QExtensionFactory class provides a standard extension factory,
|
|---|
| 735 | and can also be used as an interface for custom extension
|
|---|
| 736 | factories. You can either create a new QExtensionFactory and
|
|---|
| 737 | reimplement the QExtensionFactory::createExtension() function. For
|
|---|
| 738 | example:
|
|---|
| 739 |
|
|---|
| 740 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 10
|
|---|
| 741 |
|
|---|
| 742 | Or you can use an existing factory, expanding the
|
|---|
| 743 | QExtensionFactory::createExtension() function to make the factory
|
|---|
| 744 | able to create a task menu extension as well. For example:
|
|---|
| 745 |
|
|---|
| 746 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 11
|
|---|
| 747 |
|
|---|
| 748 | For a complete example using the QDesignerTaskMenuExtension class,
|
|---|
| 749 | see the \l {designer/taskmenuextension}{Task Menu Extension
|
|---|
| 750 | example}. The example shows how to create a custom widget plugin
|
|---|
| 751 | for \QD, and how to to use the QDesignerTaskMenuExtension
|
|---|
| 752 | class to add custom items to \QD's task menu.
|
|---|
| 753 |
|
|---|
| 754 | \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
|
|---|
| 755 | Extensions}
|
|---|
| 756 | */
|
|---|
| 757 |
|
|---|
| 758 | /*!
|
|---|
| 759 | \fn QDesignerTaskMenuExtension::~QDesignerTaskMenuExtension()
|
|---|
| 760 |
|
|---|
| 761 | Destroys the task menu extension.
|
|---|
| 762 | */
|
|---|
| 763 |
|
|---|
| 764 | /*!
|
|---|
| 765 | \fn QAction *QDesignerTaskMenuExtension::preferredEditAction() const
|
|---|
| 766 |
|
|---|
| 767 | Returns the action that is invoked when selecting a plugin with
|
|---|
| 768 | the specified extension and pressing \key F2.
|
|---|
| 769 |
|
|---|
| 770 | The action must be one of the actions returned by taskActions().
|
|---|
| 771 | */
|
|---|
| 772 |
|
|---|
| 773 | /*!
|
|---|
| 774 | \fn QList<QAction*> QDesignerTaskMenuExtension::taskActions() const
|
|---|
| 775 |
|
|---|
| 776 | Returns the task menu extension as a list of actions which will be
|
|---|
| 777 | included in \QD's task menu when a plugin with the specified
|
|---|
| 778 | extension is selected.
|
|---|
| 779 |
|
|---|
| 780 | The function must be reimplemented to add actions to the list.
|
|---|
| 781 | */
|
|---|
| 782 |
|
|---|
| 783 |
|
|---|
| 784 | // Doc: Interface only
|
|---|
| 785 |
|
|---|
| 786 | /*!
|
|---|
| 787 | \class QDesignerCustomWidgetCollectionInterface
|
|---|
| 788 |
|
|---|
| 789 | \brief The QDesignerCustomWidgetCollectionInterface class allows
|
|---|
| 790 | you to include several custom widgets in one single library.
|
|---|
| 791 |
|
|---|
| 792 | \inmodule QtDesigner
|
|---|
| 793 |
|
|---|
| 794 | When implementing a custom widget plugin, you build it as a
|
|---|
| 795 | separate library. If you want to include several custom widget
|
|---|
| 796 | plugins in the same library, you must in addition subclass
|
|---|
| 797 | QDesignerCustomWidgetCollectionInterface.
|
|---|
| 798 |
|
|---|
| 799 | QDesignerCustomWidgetCollectionInterface contains one single
|
|---|
| 800 | function returning a list of the collection's
|
|---|
| 801 | QDesignerCustomWidgetInterface objects. For example, if you have
|
|---|
| 802 | several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and
|
|---|
| 803 | \c CustomWidgetThree, the class definition may look like this:
|
|---|
| 804 |
|
|---|
| 805 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 12
|
|---|
| 806 |
|
|---|
| 807 | In the class constructor you add the interfaces to your custom
|
|---|
| 808 | widgets to the list which you return in the customWidgets()
|
|---|
| 809 | function:
|
|---|
| 810 |
|
|---|
| 811 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 13
|
|---|
| 812 |
|
|---|
| 813 | Note that instead of exporting each custom widget plugin using the
|
|---|
| 814 | Q_EXPORT_PLUGIN2() macro, you export the entire collection. The
|
|---|
| 815 | Q_EXPORT_PLUGIN2() macro ensures that \QD can access and construct
|
|---|
| 816 | the custom widgets. Without this macro, there is no way for \QD to
|
|---|
| 817 | use them.
|
|---|
| 818 |
|
|---|
| 819 | \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for
|
|---|
| 820 | Qt Designer}
|
|---|
| 821 | */
|
|---|
| 822 |
|
|---|
| 823 | /*!
|
|---|
| 824 | \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() {
|
|---|
| 825 |
|
|---|
| 826 | Destroys the custom widget collection interface.
|
|---|
| 827 | */
|
|---|
| 828 |
|
|---|
| 829 | /*!
|
|---|
| 830 | \fn QList<QDesignerCustomWidgetInterface*> QDesignerCustomWidgetCollectionInterface::customWidgets() const
|
|---|
| 831 |
|
|---|
| 832 | Returns a list of interfaces to the collection's custom widgets.
|
|---|
| 833 | */
|
|---|
| 834 |
|
|---|
| 835 |
|
|---|
| 836 | // Doc: Interface only
|
|---|
| 837 |
|
|---|
| 838 | /*!
|
|---|
| 839 | \class QDesignerCustomWidgetInterface
|
|---|
| 840 |
|
|---|
| 841 | \brief The QDesignerCustomWidgetInterface class enables Qt Designer
|
|---|
| 842 | to access and construct custom widgets.
|
|---|
| 843 |
|
|---|
| 844 | \inmodule QtDesigner
|
|---|
| 845 |
|
|---|
| 846 | QDesignerCustomWidgetInterface provides a custom widget with an
|
|---|
| 847 | interface. The class contains a set of functions that must be subclassed
|
|---|
| 848 | to return basic information about the widget, such as its class name and
|
|---|
| 849 | the name of its header file. Other functions must be implemented to
|
|---|
| 850 | initialize the plugin when it is loaded, and to construct instances of
|
|---|
| 851 | the custom widget for \QD to use.
|
|---|
| 852 |
|
|---|
| 853 | When implementing a custom widget you must subclass
|
|---|
| 854 | QDesignerCustomWidgetInterface to expose your widget to \QD. For
|
|---|
| 855 | example, this is the declaration for the plugin used in the
|
|---|
| 856 | \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that
|
|---|
| 857 | enables an analog clock custom widget to be used by \QD:
|
|---|
| 858 |
|
|---|
| 859 | \snippet examples/designer/customwidgetplugin/customwidgetplugin.h 0
|
|---|
| 860 |
|
|---|
| 861 | Note that the only part of the class definition that is specific
|
|---|
| 862 | to this particular custom widget is the class name. In addition,
|
|---|
| 863 | since we are implementing an interface, we must ensure that it's
|
|---|
| 864 | made known to the meta object system using the Q_INTERFACES()
|
|---|
| 865 | macro. This enables \QD to use the qobject_cast() function to
|
|---|
| 866 | query for supported interfaces using nothing but a QObject
|
|---|
| 867 | pointer.
|
|---|
| 868 |
|
|---|
| 869 | After \QD loads a custom widget plugin, it calls the interface's
|
|---|
| 870 | initialize() function to enable it to set up any resources that it
|
|---|
| 871 | may need. This function is called with a QDesignerFormEditorInterface
|
|---|
| 872 | parameter that provides the plugin with a gateway to all of \QD's API.
|
|---|
| 873 |
|
|---|
| 874 | \QD constructs instances of the custom widget by calling the plugin's
|
|---|
| 875 | createWidget() function with a suitable parent widget. Plugins must
|
|---|
| 876 | construct and return an instance of a custom widget with the specified
|
|---|
| 877 | parent widget.
|
|---|
| 878 |
|
|---|
| 879 | In the implementation of the class you must remember to export
|
|---|
| 880 | your custom widget plugin to \QD using the Q_EXPORT_PLUGIN2()
|
|---|
| 881 | macro. For example, if a library called \c libcustomwidgetplugin.so
|
|---|
| 882 | (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget
|
|---|
| 883 | class called \c MyCustomWidget, we can export it by adding the
|
|---|
| 884 | following line to the file containing the plugin implementation:
|
|---|
| 885 |
|
|---|
| 886 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 14
|
|---|
| 887 |
|
|---|
| 888 | This macro ensures that \QD can access and construct the custom widget.
|
|---|
| 889 | Without this macro, there is no way for \QD to use it.
|
|---|
| 890 |
|
|---|
| 891 | When implementing a custom widget plugin, you build it as a
|
|---|
| 892 | separate library. If you want to include several custom widget
|
|---|
| 893 | plugins in the same library, you must in addition subclass
|
|---|
| 894 | QDesignerCustomWidgetCollectionInterface.
|
|---|
| 895 |
|
|---|
| 896 | \warning If your custom widget plugin contains QVariant
|
|---|
| 897 | properties, be aware that only the following \l
|
|---|
| 898 | {QVariant::Type}{types} are supported:
|
|---|
| 899 |
|
|---|
| 900 | \list
|
|---|
| 901 | \o QVariant::ByteArray
|
|---|
| 902 | \o QVariant::Bool
|
|---|
| 903 | \o QVariant::Color
|
|---|
| 904 | \o QVariant::Cursor
|
|---|
| 905 | \o QVariant::Date
|
|---|
| 906 | \o QVariant::DateTime
|
|---|
| 907 | \o QVariant::Double
|
|---|
| 908 | \o QVariant::Int
|
|---|
| 909 | \o QVariant::Point
|
|---|
| 910 | \o QVariant::Rect
|
|---|
| 911 | \o QVariant::Size
|
|---|
| 912 | \o QVariant::SizePolicy
|
|---|
| 913 | \o QVariant::String
|
|---|
| 914 | \o QVariant::Time
|
|---|
| 915 | \o QVariant::UInt
|
|---|
| 916 | \endlist
|
|---|
| 917 |
|
|---|
| 918 | For a complete example using the QDesignerCustomWidgetInterface
|
|---|
| 919 | class, see the \l {designer/customwidgetplugin}{Custom Widget
|
|---|
| 920 | Example}. The example shows how to create a custom widget plugin
|
|---|
| 921 | for \QD.
|
|---|
| 922 |
|
|---|
| 923 | \sa QDesignerCustomWidgetCollectionInterface {Creating Custom
|
|---|
| 924 | Widgets for Qt Designer}
|
|---|
| 925 | */
|
|---|
| 926 |
|
|---|
| 927 | /*!
|
|---|
| 928 | \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface()
|
|---|
| 929 |
|
|---|
| 930 | Destroys the custom widget interface.
|
|---|
| 931 | */
|
|---|
| 932 |
|
|---|
| 933 | /*!
|
|---|
| 934 | \fn QString QDesignerCustomWidgetInterface::name() const
|
|---|
| 935 |
|
|---|
| 936 | Returns the class name of the custom widget supplied by the interface.
|
|---|
| 937 |
|
|---|
| 938 | The name returned \e must be identical to the class name used for the
|
|---|
| 939 | custom widget.
|
|---|
| 940 | */
|
|---|
| 941 |
|
|---|
| 942 | /*!
|
|---|
| 943 | \fn QString QDesignerCustomWidgetInterface::group() const
|
|---|
| 944 |
|
|---|
| 945 | Returns the name of the group to which the custom widget belongs.
|
|---|
| 946 | */
|
|---|
| 947 |
|
|---|
| 948 | /*!
|
|---|
| 949 | \fn QString QDesignerCustomWidgetInterface::toolTip() const
|
|---|
| 950 |
|
|---|
| 951 | Returns a short description of the widget that can be used by \QD
|
|---|
| 952 | in a tool tip.
|
|---|
| 953 | */
|
|---|
| 954 |
|
|---|
| 955 | /*!
|
|---|
| 956 | \fn QString QDesignerCustomWidgetInterface::whatsThis() const
|
|---|
| 957 |
|
|---|
| 958 | Returns a description of the widget that can be used by \QD in
|
|---|
| 959 | "What's This?" help for the widget.
|
|---|
| 960 | */
|
|---|
| 961 |
|
|---|
| 962 | /*!
|
|---|
| 963 | \fn QString QDesignerCustomWidgetInterface::includeFile() const
|
|---|
| 964 |
|
|---|
| 965 | Returns the path to the include file that \l uic uses when
|
|---|
| 966 | creating code for the custom widget.
|
|---|
| 967 | */
|
|---|
| 968 |
|
|---|
| 969 | /*!
|
|---|
| 970 | \fn QIcon QDesignerCustomWidgetInterface::icon() const
|
|---|
| 971 |
|
|---|
| 972 | Returns the icon used to represent the custom widget in \QD's
|
|---|
| 973 | widget box.
|
|---|
| 974 | */
|
|---|
| 975 |
|
|---|
| 976 | /*!
|
|---|
| 977 | \fn bool QDesignerCustomWidgetInterface::isContainer() const
|
|---|
| 978 |
|
|---|
| 979 | Returns true if the custom widget is intended to be used as a
|
|---|
| 980 | container; otherwise returns false.
|
|---|
| 981 |
|
|---|
| 982 | Most custom widgets are not used to hold other widgets, so their
|
|---|
| 983 | implementations of this function will return false, but custom
|
|---|
| 984 | containers will return true to ensure that they behave correctly
|
|---|
| 985 | in \QD.
|
|---|
| 986 | */
|
|---|
| 987 |
|
|---|
| 988 | /*!
|
|---|
| 989 | \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent)
|
|---|
| 990 |
|
|---|
| 991 | Returns a new instance of the custom widget, with the given \a
|
|---|
| 992 | parent.
|
|---|
| 993 | */
|
|---|
| 994 |
|
|---|
| 995 | /*!
|
|---|
| 996 | \fn bool QDesignerCustomWidgetInterface::isInitialized() const
|
|---|
| 997 |
|
|---|
| 998 | Returns true if the widget has been initialized; otherwise returns
|
|---|
| 999 | false.
|
|---|
| 1000 |
|
|---|
| 1001 | \sa initialize()
|
|---|
| 1002 | */
|
|---|
| 1003 |
|
|---|
| 1004 | /*!
|
|---|
| 1005 | \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor)
|
|---|
| 1006 |
|
|---|
| 1007 | Initializes the widget for use with the specified \a formEditor
|
|---|
| 1008 | interface.
|
|---|
| 1009 |
|
|---|
| 1010 | \sa isInitialized()
|
|---|
| 1011 | */
|
|---|
| 1012 |
|
|---|
| 1013 | /*!
|
|---|
| 1014 | \fn QString QDesignerCustomWidgetInterface::domXml() const
|
|---|
| 1015 |
|
|---|
| 1016 | Returns the XML that is used to describe the custom widget's
|
|---|
| 1017 | properties to \QD.
|
|---|
| 1018 | */
|
|---|
| 1019 |
|
|---|
| 1020 | /*!
|
|---|
| 1021 | \fn QString QDesignerCustomWidgetInterface::codeTemplate() const
|
|---|
| 1022 |
|
|---|
| 1023 | This function is reserved for future use by \QD.
|
|---|
| 1024 |
|
|---|
| 1025 | \omit
|
|---|
| 1026 | Returns the code template that \QD includes in forms that contain
|
|---|
| 1027 | the custom widget when they are saved.
|
|---|
| 1028 | \endomit
|
|---|
| 1029 | */
|
|---|
| 1030 |
|
|---|
| 1031 | /*!
|
|---|
| 1032 | \macro QDESIGNER_WIDGET_EXPORT
|
|---|
| 1033 | \relates QDesignerCustomWidgetInterface
|
|---|
| 1034 | \since 4.1
|
|---|
| 1035 |
|
|---|
| 1036 | This macro is used when defining custom widgets to ensure that they are
|
|---|
| 1037 | correctly exported from plugins for use with \QD.
|
|---|
| 1038 |
|
|---|
| 1039 | On some platforms, the symbols required by \QD to create new widgets
|
|---|
| 1040 | are removed from plugins by the build system, making them unusable.
|
|---|
| 1041 | Using this macro ensures that the symbols are retained on those platforms,
|
|---|
| 1042 | and has no side effects on other platforms.
|
|---|
| 1043 |
|
|---|
| 1044 | For example, the \l{designer/worldtimeclockplugin}{World Time Clock Plugin}
|
|---|
| 1045 | example exports a custom widget class with the following declaration:
|
|---|
| 1046 |
|
|---|
| 1047 | \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 0
|
|---|
| 1048 | \dots
|
|---|
| 1049 | \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 2
|
|---|
| 1050 |
|
|---|
| 1051 | \sa {Creating Custom Widgets for Qt Designer}
|
|---|
| 1052 | */
|
|---|
| 1053 |
|
|---|
| 1054 |
|
|---|
| 1055 | // Doc: Abstract class
|
|---|
| 1056 |
|
|---|
| 1057 | /*!
|
|---|
| 1058 | \class QDesignerDnDItemInterface
|
|---|
| 1059 | \brief The QDesignerDnDItemInterface class provides an interface that is used to manage items
|
|---|
| 1060 | during a drag and drop operation.
|
|---|
| 1061 | \inmodule QtDesigner
|
|---|
| 1062 | \internal
|
|---|
| 1063 | */
|
|---|
| 1064 |
|
|---|
| 1065 | /*!
|
|---|
| 1066 | \enum QDesignerDnDItemInterface::DropType
|
|---|
| 1067 |
|
|---|
| 1068 | This enum describes the result of a drag and drop operation.
|
|---|
| 1069 |
|
|---|
| 1070 | \value MoveDrop The item was moved.
|
|---|
| 1071 | \value CopyDrop The item was copied.
|
|---|
| 1072 | */
|
|---|
| 1073 |
|
|---|
| 1074 | /*!
|
|---|
| 1075 | \fn QDesignerDnDItemInterface::QDesignerDnDItemInterface()
|
|---|
| 1076 |
|
|---|
| 1077 | Constructs a new interface to a drag and drop item.
|
|---|
| 1078 | */
|
|---|
| 1079 |
|
|---|
| 1080 | /*!
|
|---|
| 1081 | \fn QDesignerDnDItemInterface::~QDesignerDnDItemInterface()
|
|---|
| 1082 |
|
|---|
| 1083 | Destroys the interface to the item.
|
|---|
| 1084 | */
|
|---|
| 1085 |
|
|---|
| 1086 | /*!
|
|---|
| 1087 | \fn DomUI *QDesignerDnDItemInterface::domUi() const
|
|---|
| 1088 |
|
|---|
| 1089 | Returns a user interface object for the item.
|
|---|
| 1090 | */
|
|---|
| 1091 |
|
|---|
| 1092 | /*!
|
|---|
| 1093 | \fn QWidget *QDesignerDnDItemInterface::widget() const
|
|---|
| 1094 |
|
|---|
| 1095 | Returns the widget being copied or moved in the drag and drop operation.
|
|---|
| 1096 |
|
|---|
| 1097 | \sa source()
|
|---|
| 1098 | */
|
|---|
| 1099 |
|
|---|
| 1100 | /*!
|
|---|
| 1101 | \fn QWidget *QDesignerDnDItemInterface::decoration() const
|
|---|
| 1102 |
|
|---|
| 1103 | Returns the widget used to represent the item.
|
|---|
| 1104 | */
|
|---|
| 1105 |
|
|---|
| 1106 | /*!
|
|---|
| 1107 | \fn QPoint QDesignerDnDItemInterface::hotSpot() const
|
|---|
| 1108 |
|
|---|
| 1109 | Returns the cursor's hotspot.
|
|---|
| 1110 |
|
|---|
| 1111 | \sa QDrag::hotSpot()
|
|---|
| 1112 | */
|
|---|
| 1113 |
|
|---|
| 1114 | /*!
|
|---|
| 1115 | \fn DropType QDesignerDnDItemInterface::type() const
|
|---|
| 1116 |
|
|---|
| 1117 | Returns the type of drag and drop operation in progress.
|
|---|
| 1118 | */
|
|---|
| 1119 |
|
|---|
| 1120 | /*!
|
|---|
| 1121 | \fn QWidget *QDesignerDnDItemInterface::source() const
|
|---|
| 1122 |
|
|---|
| 1123 | Returns the widget that is the source of the drag and drop operation; i.e. the original
|
|---|
| 1124 | container of the widget being dragged.
|
|---|
| 1125 |
|
|---|
| 1126 | \sa widget()
|
|---|
| 1127 | */
|
|---|
| 1128 |
|
|---|
| 1129 |
|
|---|
| 1130 | // Doc: Abstract class
|
|---|
| 1131 |
|
|---|
| 1132 | /*!
|
|---|
| 1133 | \class QDesignerIconCacheInterface
|
|---|
| 1134 | \brief The QDesignerIconCacheInterface class provides an interface to \QD's icon cache.
|
|---|
| 1135 | \inmodule QtDesigner
|
|---|
| 1136 | \internal
|
|---|
| 1137 | */
|
|---|
| 1138 |
|
|---|
| 1139 | /*!
|
|---|
| 1140 | \fn QDesignerIconCacheInterface::QDesignerIconCacheInterface(QObject *parent)
|
|---|
| 1141 |
|
|---|
| 1142 | Constructs a new interface with the given \a parent.
|
|---|
| 1143 | */
|
|---|
| 1144 |
|
|---|
| 1145 | /*!
|
|---|
| 1146 | \fn QIcon QDesignerIconCacheInterface::nameToIcon(const QString &filePath, const QString &qrcPath)
|
|---|
| 1147 |
|
|---|
| 1148 | Returns the icon associated with the name specified by \a filePath in the resource
|
|---|
| 1149 | file specified by \a qrcPath.
|
|---|
| 1150 |
|
|---|
| 1151 | If \a qrcPath refers to a valid resource file, the name used for the file path is a path
|
|---|
| 1152 | within those resources; otherwise the file path refers to a local file.
|
|---|
| 1153 |
|
|---|
| 1154 | \sa {The Qt Resource System}, nameToPixmap()
|
|---|
| 1155 | */
|
|---|
| 1156 |
|
|---|
| 1157 | /*!
|
|---|
| 1158 | \fn QPixmap QDesignerIconCacheInterface::nameToPixmap(const QString &filePath, const QString &qrcPath)
|
|---|
| 1159 |
|
|---|
| 1160 | Returns the pixmap associated with the name specified by \a filePath in the resource
|
|---|
| 1161 | file specified by \a qrcPath.
|
|---|
| 1162 |
|
|---|
| 1163 | If \a qrcPath refers to a valid resource file, the name used for the file path is a path
|
|---|
| 1164 | within those resources; otherwise the file path refers to a local file.
|
|---|
| 1165 |
|
|---|
| 1166 | \sa {The Qt Resource System}, nameToIcon()
|
|---|
| 1167 | */
|
|---|
| 1168 |
|
|---|
| 1169 | /*!
|
|---|
| 1170 | \fn QString QDesignerIconCacheInterface::iconToFilePath(const QIcon &icon) const
|
|---|
| 1171 |
|
|---|
| 1172 | Returns the file path associated with the given \a icon. The file path is a path within
|
|---|
| 1173 | an application resources.
|
|---|
| 1174 | */
|
|---|
| 1175 |
|
|---|
| 1176 | /*!
|
|---|
| 1177 | \fn QString QDesignerIconCacheInterface::iconToQrcPath(const QIcon &icon) const
|
|---|
| 1178 |
|
|---|
| 1179 | Returns the path to the resource file that refers to the specified \a icon. The resource
|
|---|
| 1180 | path refers to a local file.
|
|---|
| 1181 | */
|
|---|
| 1182 |
|
|---|
| 1183 | /*!
|
|---|
| 1184 | \fn QString QDesignerIconCacheInterface::pixmapToFilePath(const QPixmap &pixmap) const
|
|---|
| 1185 |
|
|---|
| 1186 | Returns the file path associated with the given \a pixmap. The file path is a path within
|
|---|
| 1187 | an application resources.
|
|---|
| 1188 | */
|
|---|
| 1189 |
|
|---|
| 1190 | /*!
|
|---|
| 1191 | \fn QString QDesignerIconCacheInterface::pixmapToQrcPath(const QPixmap &pixmap) const
|
|---|
| 1192 |
|
|---|
| 1193 | Returns the path to the resource file that refers to the specified \a pixmap. The resource
|
|---|
| 1194 | path refers to a local file.
|
|---|
| 1195 | */
|
|---|
| 1196 |
|
|---|
| 1197 | /*!
|
|---|
| 1198 | \fn QList<QPixmap> QDesignerIconCacheInterface::pixmapList() const
|
|---|
| 1199 |
|
|---|
| 1200 | Returns a list of pixmaps for the icons provided by the icon cache.
|
|---|
| 1201 | */
|
|---|
| 1202 |
|
|---|
| 1203 | /*!
|
|---|
| 1204 | \fn QList<QIcon> QDesignerIconCacheInterface::iconList() const
|
|---|
| 1205 |
|
|---|
| 1206 | Returns a list of icons provided by the icon cache.
|
|---|
| 1207 | */
|
|---|
| 1208 |
|
|---|
| 1209 | /*!
|
|---|
| 1210 | \fn QString QDesignerIconCacheInterface::resolveQrcPath(const QString &filePath, const QString &qrcPath, const QString &workingDirectory) const
|
|---|
| 1211 |
|
|---|
| 1212 | Returns a path to a resource specified by the \a filePath within
|
|---|
| 1213 | the resource file located at \a qrcPath. If \a workingDirectory is
|
|---|
| 1214 | a valid path to a directory, the path returned will be relative to
|
|---|
| 1215 | that directory; otherwise an absolute path is returned.
|
|---|
| 1216 |
|
|---|
| 1217 | \omit
|
|---|
| 1218 | ### Needs checking
|
|---|
| 1219 | \endomit
|
|---|
| 1220 | */
|
|---|
| 1221 |
|
|---|
| 1222 |
|
|---|
| 1223 | // Doc: Interface only
|
|---|
| 1224 |
|
|---|
| 1225 | /*!
|
|---|
| 1226 | \class QDesignerPropertySheetExtension
|
|---|
| 1227 |
|
|---|
| 1228 | \brief The QDesignerPropertySheetExtension class allows you to
|
|---|
| 1229 | manipulate a widget's properties which is displayed in Qt
|
|---|
| 1230 | Designer's property editor.
|
|---|
| 1231 |
|
|---|
| 1232 | \sa QDesignerDynamicPropertySheetExtension
|
|---|
| 1233 |
|
|---|
| 1234 | \inmodule QtDesigner
|
|---|
| 1235 |
|
|---|
| 1236 | QDesignerPropertySheetExtension provides a collection of functions that
|
|---|
| 1237 | are typically used to query a widget's properties, and to
|
|---|
| 1238 | manipulate the properties' appearance in the property editor. For
|
|---|
| 1239 | example:
|
|---|
| 1240 |
|
|---|
| 1241 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 15
|
|---|
| 1242 |
|
|---|
| 1243 | Note that if you change the value of a property using the
|
|---|
| 1244 | QDesignerPropertySheetExtension::setProperty() function, the undo
|
|---|
| 1245 | stack is not updated. To ensure that a property's value can be
|
|---|
| 1246 | reverted using the undo stack, you must use the
|
|---|
| 1247 | QDesignerFormWindowCursorInterface::setProperty() function, or its
|
|---|
| 1248 | buddy \l
|
|---|
| 1249 | {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
|
|---|
| 1250 | instead.
|
|---|
| 1251 |
|
|---|
| 1252 | When implementing a custom widget plugin, a pointer to \QD's
|
|---|
| 1253 | current QDesignerFormEditorInterface object (\c formEditor in the
|
|---|
| 1254 | example above) is provided by the
|
|---|
| 1255 | QDesignerCustomWidgetInterface::initialize() function's parameter.
|
|---|
| 1256 |
|
|---|
| 1257 | The property sheet, or any other extension, can be retrieved by
|
|---|
| 1258 | querying \QD's extension manager using the qt_extension()
|
|---|
| 1259 | function. When you want to release the extension, you only need to
|
|---|
| 1260 | delete the pointer.
|
|---|
| 1261 |
|
|---|
| 1262 | All widgets have a default property sheet which populates \QD's
|
|---|
| 1263 | property editor with the widget's properties (i.e the ones defined
|
|---|
| 1264 | with the Q_PROPERTY() macro). But QDesignerPropertySheetExtension
|
|---|
| 1265 | also provides an interface for creating custom property sheet
|
|---|
| 1266 | extensions.
|
|---|
| 1267 |
|
|---|
| 1268 | \warning \QD uses the QDesignerPropertySheetExtension to feed its
|
|---|
| 1269 | property editor. Whenever a widget is selected in its workspace,
|
|---|
| 1270 | \QD will query for the widget's property sheet extension. If the
|
|---|
| 1271 | selected widget has an implemented property sheet extension, this
|
|---|
| 1272 | extension will override the default property sheet.
|
|---|
| 1273 |
|
|---|
| 1274 | To create a property sheet extension, your extension class must
|
|---|
| 1275 | inherit from both QObject and
|
|---|
| 1276 | QDesignerPropertySheetExtension. Then, since we are implementing
|
|---|
| 1277 | an interface, we must ensure that it's made known to the meta
|
|---|
| 1278 | object system using the Q_INTERFACES() macro:
|
|---|
| 1279 |
|
|---|
| 1280 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 16
|
|---|
| 1281 |
|
|---|
| 1282 | This enables \QD to use qobject_cast() to query for supported
|
|---|
| 1283 | interfaces using nothing but a QObject pointer.
|
|---|
| 1284 |
|
|---|
| 1285 | In \QD the extensions are not created until they are
|
|---|
| 1286 | required. For that reason, when implementing a property sheet
|
|---|
| 1287 | extension, you must also create a QExtensionFactory, i.e a class
|
|---|
| 1288 | that is able to make an instance of your extension, and register
|
|---|
| 1289 | it using \QD's \l {QExtensionManager}{extension manager}.
|
|---|
| 1290 |
|
|---|
| 1291 | When a property sheet extension is required, \QD's \l
|
|---|
| 1292 | {QExtensionManager}{extension manager} will run through all its
|
|---|
| 1293 | registered factories calling QExtensionFactory::createExtension()
|
|---|
| 1294 | for each until the first one that is able to create a property
|
|---|
| 1295 | sheet extension for the selected widget, is found. This factory
|
|---|
| 1296 | will then make an instance of the extension. If no such factory
|
|---|
| 1297 | can be found, \QD will use the default property sheet.
|
|---|
| 1298 |
|
|---|
| 1299 | There are four available types of extensions in \QD:
|
|---|
| 1300 | QDesignerContainerExtension, QDesignerMemberSheetExtension,
|
|---|
| 1301 | QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt
|
|---|
| 1302 | Designer's behavior is the same whether the requested extension is
|
|---|
| 1303 | associated with a multi page container, a member sheet, a property
|
|---|
| 1304 | sheet or a task menu.
|
|---|
| 1305 |
|
|---|
| 1306 | The QExtensionFactory class provides a standard extension factory,
|
|---|
| 1307 | and can also be used as an interface for custom extension
|
|---|
| 1308 | factories. You can either create a new QExtensionFactory and
|
|---|
| 1309 | reimplement the QExtensionFactory::createExtension() function. For
|
|---|
| 1310 | example:
|
|---|
| 1311 |
|
|---|
| 1312 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 17
|
|---|
| 1313 |
|
|---|
| 1314 | Or you can use an existing factory, expanding the
|
|---|
| 1315 | QExtensionFactory::createExtension() function to make the factory
|
|---|
| 1316 | able to create a property sheet extension extension as well. For
|
|---|
| 1317 | example:
|
|---|
| 1318 |
|
|---|
| 1319 | \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 18
|
|---|
| 1320 |
|
|---|
| 1321 | For a complete example using an extension class, see the \l
|
|---|
| 1322 | {designer/taskmenuextension}{Task Menu Extension example}. The
|
|---|
| 1323 | example shows how to create a custom widget plugin for Qt
|
|---|
| 1324 | Designer, and how to to use the QDesignerTaskMenuExtension class
|
|---|
| 1325 | to add custom items to \QD's task menu.
|
|---|
| 1326 |
|
|---|
| 1327 | \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
|
|---|
| 1328 | Extensions}
|
|---|
| 1329 | */
|
|---|
| 1330 |
|
|---|
| 1331 | /*!
|
|---|
| 1332 | \fn QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension()
|
|---|
| 1333 |
|
|---|
| 1334 | Destroys the property sheet extension.
|
|---|
| 1335 | */
|
|---|
| 1336 |
|
|---|
| 1337 | /*!
|
|---|
| 1338 | \fn int QDesignerPropertySheetExtension::count() const
|
|---|
| 1339 |
|
|---|
| 1340 | Returns the selected widget's number of properties.
|
|---|
| 1341 | */
|
|---|
| 1342 |
|
|---|
| 1343 | /*!
|
|---|
| 1344 | \fn int QDesignerPropertySheetExtension::indexOf(const QString &name) const
|
|---|
| 1345 |
|
|---|
| 1346 | Returns the index for a given property \a name.
|
|---|
| 1347 |
|
|---|
| 1348 | \sa propertyName()
|
|---|
| 1349 | */
|
|---|
| 1350 |
|
|---|
| 1351 | /*!
|
|---|
| 1352 | \fn QString QDesignerPropertySheetExtension::propertyName(int index) const
|
|---|
| 1353 |
|
|---|
| 1354 | Returns the name of the property at the given \a index.
|
|---|
| 1355 |
|
|---|
| 1356 | \sa indexOf()
|
|---|
| 1357 | */
|
|---|
| 1358 |
|
|---|
| 1359 | /*!
|
|---|
| 1360 | \fn QString QDesignerPropertySheetExtension::propertyGroup(int index) const
|
|---|
| 1361 |
|
|---|
| 1362 | Returns the property group for the property at the given \a index.
|
|---|
| 1363 |
|
|---|
| 1364 | \QD's property editor supports property groups, i.e. sections of
|
|---|
| 1365 | related properties. A property can be related to a group using the
|
|---|
| 1366 | setPropertyGroup() function. The default group of any property is
|
|---|
| 1367 | the name of the class that defines it. For example, the
|
|---|
| 1368 | QObject::objectName property appears within the QObject property
|
|---|
| 1369 | group.
|
|---|
| 1370 |
|
|---|
| 1371 | \sa indexOf(), setPropertyGroup()
|
|---|
| 1372 | */
|
|---|
| 1373 |
|
|---|
| 1374 | /*!
|
|---|
| 1375 | \fn void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group)
|
|---|
| 1376 |
|
|---|
| 1377 | Sets the property group for the property at the given \a index to
|
|---|
| 1378 | \a group.
|
|---|
| 1379 |
|
|---|
| 1380 | Relating a property to a group makes it appear within that group's
|
|---|
| 1381 | section in the property editor. The default property group of any
|
|---|
| 1382 | property is the name of the class that defines it. For example,
|
|---|
| 1383 | the QObject::objectName property appears within the QObject
|
|---|
| 1384 | property group.
|
|---|
| 1385 |
|
|---|
| 1386 | \sa indexOf(), property(), propertyGroup()
|
|---|
| 1387 | */
|
|---|
| 1388 |
|
|---|
| 1389 | /*!
|
|---|
| 1390 | \fn bool QDesignerPropertySheetExtension::hasReset(int index) const
|
|---|
| 1391 |
|
|---|
| 1392 | Returns true if the property at the given \a index has a reset
|
|---|
| 1393 | button in \QD's property editor, otherwise false.
|
|---|
| 1394 |
|
|---|
| 1395 | \sa indexOf(), reset()
|
|---|
| 1396 | */
|
|---|
| 1397 |
|
|---|
| 1398 | /*!
|
|---|
| 1399 | \fn bool QDesignerPropertySheetExtension::reset(int index)
|
|---|
| 1400 |
|
|---|
| 1401 | Resets the value of the property at the given \a index, to the
|
|---|
| 1402 | default value. Returns true if a default value could be found, otherwise false.
|
|---|
| 1403 |
|
|---|
| 1404 | \sa indexOf(), hasReset(), isChanged()
|
|---|
| 1405 | */
|
|---|
| 1406 |
|
|---|
| 1407 | /*!
|
|---|
| 1408 | \fn bool QDesignerPropertySheetExtension::isVisible(int index) const
|
|---|
| 1409 |
|
|---|
| 1410 | Returns true if the property at the given \a index is visible in
|
|---|
| 1411 | \QD's property editor, otherwise false.
|
|---|
| 1412 |
|
|---|
| 1413 | \sa indexOf(), setVisible()
|
|---|
| 1414 | */
|
|---|
| 1415 |
|
|---|
| 1416 | /*!
|
|---|
| 1417 | \fn void QDesignerPropertySheetExtension::setVisible(int index, bool visible)
|
|---|
| 1418 |
|
|---|
| 1419 | If \a visible is true, the property at the given \a index is
|
|---|
| 1420 | visible in \QD's property editor; otherwise the property is
|
|---|
| 1421 | hidden.
|
|---|
| 1422 |
|
|---|
| 1423 | \sa indexOf(), isVisible()
|
|---|
| 1424 | */
|
|---|
| 1425 |
|
|---|
| 1426 | /*!
|
|---|
| 1427 | \fn bool QDesignerPropertySheetExtension::isAttribute(int index) const
|
|---|
| 1428 |
|
|---|
| 1429 | Returns true if the property at the given \a index is an attribute,
|
|---|
| 1430 | which will be \e excluded from the .ui file, otherwise false.
|
|---|
| 1431 |
|
|---|
| 1432 | \sa indexOf(), setAttribute()
|
|---|
| 1433 | */
|
|---|
| 1434 |
|
|---|
| 1435 | /*!
|
|---|
| 1436 | \fn void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute)
|
|---|
| 1437 |
|
|---|
| 1438 | If \a attribute is true, the property at the given \a index is
|
|---|
| 1439 | made an attribute which will be \e excluded from the .ui file;
|
|---|
| 1440 | otherwise it will be included.
|
|---|
| 1441 |
|
|---|
| 1442 | \sa indexOf(), isAttribute()
|
|---|
| 1443 | */
|
|---|
| 1444 |
|
|---|
| 1445 | /*!
|
|---|
| 1446 | \fn QVariant QDesignerPropertySheetExtension::property(int index) const
|
|---|
| 1447 |
|
|---|
| 1448 | Returns the value of the property at the given \a index.
|
|---|
| 1449 |
|
|---|
| 1450 | \sa indexOf(), setProperty(), propertyGroup()
|
|---|
| 1451 | */
|
|---|
| 1452 |
|
|---|
| 1453 | /*!
|
|---|
| 1454 | \fn void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value)
|
|---|
| 1455 |
|
|---|
| 1456 | Sets the \a value of the property at the given \a index.
|
|---|
| 1457 |
|
|---|
| 1458 | \warning If you change the value of a property using this
|
|---|
| 1459 | function, the undo stack is not updated. To ensure that a
|
|---|
| 1460 | property's value can be reverted using the undo stack, you must
|
|---|
| 1461 | use the QDesignerFormWindowCursorInterface::setProperty()
|
|---|
| 1462 | function, or its buddy \l
|
|---|
| 1463 | {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
|
|---|
| 1464 | instead.
|
|---|
| 1465 |
|
|---|
| 1466 | \sa indexOf(), property(), propertyGroup()
|
|---|
| 1467 | */
|
|---|
| 1468 |
|
|---|
| 1469 | /*!
|
|---|
| 1470 | \fn bool QDesignerPropertySheetExtension::isChanged(int index) const
|
|---|
| 1471 |
|
|---|
| 1472 | Returns true if the value of the property at the given \a index
|
|---|
| 1473 | differs from the property's default value, otherwise false.
|
|---|
| 1474 |
|
|---|
| 1475 | \sa indexOf(), setChanged(), reset()
|
|---|
| 1476 | */
|
|---|
| 1477 |
|
|---|
| 1478 | /*!
|
|---|
| 1479 | \fn void QDesignerPropertySheetExtension::setChanged(int index, bool changed)
|
|---|
| 1480 |
|
|---|
| 1481 | Sets whether the property at the given \a index is different from
|
|---|
| 1482 | its default value, or not, depending on the \a changed parameter.
|
|---|
| 1483 |
|
|---|
| 1484 | \sa indexOf(), isChanged()
|
|---|
| 1485 | */
|
|---|
| 1486 |
|
|---|
| 1487 | // Doc: Interface only
|
|---|
| 1488 |
|
|---|
| 1489 | /*!
|
|---|
| 1490 | \class QDesignerDynamicPropertySheetExtension
|
|---|
| 1491 |
|
|---|
| 1492 | \brief The QDesignerDynamicPropertySheetExtension class allows you to
|
|---|
| 1493 | manipulate a widget's dynamic properties in Qt Designer's property editor.
|
|---|
| 1494 |
|
|---|
| 1495 | \sa QDesignerPropertySheetExtension, {QObject#Dynamic Properties}{Dynamic Properties}
|
|---|
| 1496 |
|
|---|
| 1497 | \inmodule QtDesigner
|
|---|
| 1498 | \since 4.3
|
|---|
| 1499 | */
|
|---|
| 1500 |
|
|---|
| 1501 | /*!
|
|---|
| 1502 | \fn QDesignerDynamicPropertySheetExtension::~QDesignerDynamicPropertySheetExtension()
|
|---|
| 1503 |
|
|---|
| 1504 | Destroys the dynamic property sheet extension.
|
|---|
| 1505 | */
|
|---|
| 1506 |
|
|---|
| 1507 | /*!
|
|---|
| 1508 | \fn bool QDesignerDynamicPropertySheetExtension::dynamicPropertiesAllowed() const
|
|---|
| 1509 |
|
|---|
| 1510 | Returns true if the widget supports dynamic properties; otherwise returns false.
|
|---|
| 1511 | */
|
|---|
| 1512 |
|
|---|
| 1513 | /*!
|
|---|
| 1514 | \fn int QDesignerDynamicPropertySheetExtension::addDynamicProperty(const QString &propertyName, const QVariant &value)
|
|---|
| 1515 |
|
|---|
| 1516 | Adds a dynamic property named \a propertyName and sets its value to \a value.
|
|---|
| 1517 | Returns the index of the property if it was added successfully; otherwise returns -1 to
|
|---|
| 1518 | indicate failure.
|
|---|
| 1519 | */
|
|---|
| 1520 |
|
|---|
| 1521 | /*!
|
|---|
| 1522 | \fn bool QDesignerDynamicPropertySheetExtension::removeDynamicProperty(int index)
|
|---|
| 1523 |
|
|---|
| 1524 | Removes the dynamic property at the given \a index.
|
|---|
| 1525 | Returns true if the operation succeeds; otherwise returns false.
|
|---|
| 1526 | */
|
|---|
| 1527 |
|
|---|
| 1528 | /*!
|
|---|
| 1529 | \fn bool QDesignerDynamicPropertySheetExtension::isDynamicProperty(int index) const
|
|---|
| 1530 |
|
|---|
| 1531 | Returns true if the property at the given \a index is a dynamic property; otherwise
|
|---|
| 1532 | returns false.
|
|---|
| 1533 | */
|
|---|
| 1534 |
|
|---|
| 1535 | /*!
|
|---|
| 1536 | \fn bool QDesignerDynamicPropertySheetExtension::canAddDynamicProperty(const QString &propertyName) const
|
|---|
| 1537 |
|
|---|
| 1538 | Returns true if \a propertyName is a valid, unique name for a dynamic
|
|---|
| 1539 | property; otherwise returns false.
|
|---|
| 1540 |
|
|---|
| 1541 | */
|
|---|