Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QDesignerScriptExtension Class Reference
[QtDesigner module]

The QDesignerScriptExtension allows you to generate a per-widget Qt Script snippet to be executed while building the form. More...

 #include <QDesignerScriptExtension>

This class was introduced in Qt 4.3.

Public Functions


Detailed Description

The QDesignerScriptExtension allows you to generate a per-widget Qt Script snippet to be executed while building the form.

On saving the form, the extension is queried for a script snippet to be associated with the widget while saving the .ui file. This script is then run after creating the widget by uic or QUiLoader.

As opposed to QDesignerCustomWidgetInterface::codeTemplate(), it allows for applying an internal state of the widget that can be manipulated using Qt Designer.

Such a state might for example be the contents of a custom item view widget, for which an editor is provided by the QDesignerTaskMenuExtension.

While saving the form, the state is serialized as a QVariantMap of Qt Designer-supported properties, which is stored in the .ui file. This is handled by data() and setData().

For item view contents, there might be for example a key that determines the number of items and other keys that contain the actual items following a naming scheme (numItems, item1, item2, ...).

On saving, script() is invoked, which should return a script snippet that applies the state to the widget while building the form.

See also Creating Custom Widgets for Qt Designer and QtScript.


Member Function Documentation

QDesignerScriptExtension::~QDesignerScriptExtension ()   [virtual]

Destroys the extension.

QVariantMap QDesignerScriptExtension::data () const   [pure virtual]

Returns a map of variants describing the internal state to be stored in the .ui file.

See also setData().

QString QDesignerScriptExtension::script () const   [pure virtual]

Returns a script snippet to be associated with the widget.

void QDesignerScriptExtension::setData ( const QVariantMap & data )   [pure virtual]

Applies the internal state stored in data to the widget while loading a form.

See also data().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.0rc1