Designer: Extend container extension.

Make it possible to disable adding/removing pages by
adding respective bool virtual functions.

Useful for implementing containers with fixed, single
children like QScrollArea, QDockWidget, which require
a container extension to work properly in Qt Designer.
Previously, the problem was that the add/remove
page context menu actions were enabled for them,
leading to crashes und undesired behaviour.

Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com>
This commit is contained in:
Friedemann Kleint 2011-05-20 10:10:32 +02:00
parent 66498850f2
commit e00b8105bf
2 changed files with 34 additions and 0 deletions

View File

@ -65,6 +65,13 @@ public:
virtual void addWidget(QWidget *widget) = 0;
virtual void insertWidget(int index, QWidget *widget) = 0;
virtual void remove(int index) = 0;
virtual bool canAddWidget() const
// ### Qt6 remove body, provided in Qt5 for source compatibility to Qt4.
{ return true; }
virtual bool canRemove(int index) const
// ### Qt6 remove body, provided in Qt5 for source compatibility to Qt4.
{ Q_UNUSED(index); return true; }
};
Q_DECLARE_EXTENSION_INTERFACE(QDesignerContainerExtension, "com.trolltech.Qt.Designer.Container")

View File

@ -170,3 +170,30 @@
\sa addWidget(), insertWidget()
*/
/*!
\fn bool QDesignerContainerExtension::canAddWidget() const
Returns whether a widget can be added. This determines whether
the context menu options to add or insert pages are enabled.
This should return false for containers that have a single, fixed
page, for example QScrollArea or QDockWidget.
\since 5.0
\sa addWidget(), canRemove()
*/
/*!
\fn bool QDesignerContainerExtension::canRemove(int index) const
Returns whether the widget at the given \a index can be removed.
This determines whether the context menu option to remove the current
page is enabled.
This should return false for containers that have a single, fixed
page, for example QScrollArea or QDockWidget.
\since 5.0
\sa remove(), canAddWidget()
*/