<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QDesignerPropertySheetExtension Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDesignerPropertySheetExtension Class Reference<br /><sup><sup>[<a href="qtdesigner.html">QtDesigner</a> module]</sup></sup></h1><p>The QDesignerPropertySheetExtension class allows you to manipulate a widget's properties which is displayed in Qt Designer's property editor. <a href="#details">More...</a></p> <p>Inherited by <a href="qpydesignerpropertysheetextension.html">QPyDesignerPropertySheetExtension</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdesignerpropertysheetextension.html#QDesignerPropertySheetExtension">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdesignerpropertysheetextension.html#QDesignerPropertySheetExtension-2">__init__</a></b> (<i>self</i>, QDesignerPropertySheetExtension)</li><li><div class="fn" />int <b><a href="qdesignerpropertysheetextension.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdesignerpropertysheetextension.html#hasReset">hasReset</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" />int <b><a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" />bool <b><a href="qdesignerpropertysheetextension.html#isAttribute">isAttribute</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" />bool <b><a href="qdesignerpropertysheetextension.html#isChanged">isChanged</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" />bool <b><a href="qdesignerpropertysheetextension.html#isVisible">isVisible</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" />QVariant <b><a href="qdesignerpropertysheetextension.html#property">property</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" />QString <b><a href="qdesignerpropertysheetextension.html#propertyGroup">propertyGroup</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" />QString <b><a href="qdesignerpropertysheetextension.html#propertyName">propertyName</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" />bool <b><a href="qdesignerpropertysheetextension.html#reset">reset</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" /><b><a href="qdesignerpropertysheetextension.html#setAttribute">setAttribute</a></b> (<i>self</i>, int <i>index</i>, bool <i>b</i>)</li><li><div class="fn" /><b><a href="qdesignerpropertysheetextension.html#setChanged">setChanged</a></b> (<i>self</i>, int <i>index</i>, bool <i>changed</i>)</li><li><div class="fn" /><b><a href="qdesignerpropertysheetextension.html#setProperty">setProperty</a></b> (<i>self</i>, int <i>index</i>, QVariant <i>value</i>)</li><li><div class="fn" /><b><a href="qdesignerpropertysheetextension.html#setPropertyGroup">setPropertyGroup</a></b> (<i>self</i>, int <i>index</i>, QString <i>group</i>)</li><li><div class="fn" /><b><a href="qdesignerpropertysheetextension.html#setVisible">setVisible</a></b> (<i>self</i>, int <i>index</i>, bool <i>b</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" /> <b><a href="qdesignerpropertysheetextension.html#__len__">__len__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDesignerPropertySheetExtension class allows you to manipulate a widget's properties which is displayed in Qt Designer's property editor.</p> <p>QDesignerPropertySheetExtension provides a collection of functions that are typically used to query a widget's properties, and to manipulate the properties' appearance in the property editor. For example:</p> <pre class="cpp"> <span class="type">QDesignerPropertySheetExtension</span> <span class="operator">*</span>propertySheet <span class="operator">=</span> <span class="number">0</span>; <span class="type"><a href="qextensionmanager.html">QExtensionManager</a></span> manager <span class="operator">=</span> formEditor<span class="operator">-</span><span class="operator">></span>extensionManager(); propertySheet <span class="operator">=</span> qt_extension<span class="operator"><</span><span class="type">QDesignerPropertySheetExtension</span><span class="operator">*</span><span class="operator">></span>(manager<span class="operator">,</span> widget); <span class="type">int</span> index <span class="operator">=</span> propertySheet<span class="operator">-</span><span class="operator">></span><a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>(QLatin1String(<span class="string">"margin"</span>)); propertySheet<span class="operator">-</span><span class="operator">></span><a href="qdesignerpropertysheetextension.html#setProperty">setProperty</a>(index<span class="operator">,</span> <span class="number">10</span>); propertySheet<span class="operator">-</span><span class="operator">></span><a href="qdesignerpropertysheetextension.html#setChanged">setChanged</a>(index<span class="operator">,</span> <span class="keyword">true</span>); <span class="keyword">delete</span> propertySheet; </pre> <p>Note that if you change the value of a property using the <a href="qdesignerpropertysheetextension.html#setProperty">QDesignerPropertySheetExtension.setProperty</a>() function, the undo stack is not updated. To ensure that a property's value can be reverted using the undo stack, you must use the <a href="qdesignerformwindowcursorinterface.html#setProperty">QDesignerFormWindowCursorInterface.setProperty</a>() function, or its buddy <a href="qdesignerformwindowcursorinterface.html#setWidgetProperty">setWidgetProperty()</a>, instead.</p> <p>When implementing a custom widget plugin, a pointer to <i>Qt Designer</i>'s current <a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a> object (<tt>formEditor</tt> in the example above) is provided by the <a href="qdesignercustomwidgetinterface.html#initialize">QDesignerCustomWidgetInterface.initialize</a>() function's parameter.</p> <p>The property sheet, or any other extension, can be retrieved by querying <i>Qt Designer</i>'s extension manager using the <a href="qextensionmanager.html#qt_extension">qt_extension</a>() function. When you want to release the extension, you only need to delete the pointer.</p> <p>All widgets have a default property sheet which populates <i>Qt Designer</i>'s property editor with the widget's properties (i.e the ones defined with the <a href="qobject.html#Q_PROPERTY">Q_PROPERTY</a>() macro). But QDesignerPropertySheetExtension also provides an interface for creating custom property sheet extensions.</p> <p><b>Warning:</b> <i>Qt Designer</i> uses the QDesignerPropertySheetExtension to feed its property editor. Whenever a widget is selected in its workspace, <i>Qt Designer</i> will query for the widget's property sheet extension. If the selected widget has an implemented property sheet extension, this extension will override the default property sheet.</p> <p>To create a property sheet extension, your extension class must inherit from both <a href="qobject.html">QObject</a> and QDesignerPropertySheetExtension. Then, since we are implementing an interface, we must ensure that it's made known to the meta object system using the <a href="qobject.html#Q_INTERFACES">Q_INTERFACES</a>() macro:</p> <pre class="cpp"> <span class="keyword">class</span> MyPropertySheetExtension : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span><span class="operator">,</span> <span class="keyword">public</span> <span class="type">QDesignerPropertySheetExtension</span> { Q_OBJECT Q_INTERFACES(<span class="type">QDesignerPropertySheetExtension</span>) <span class="keyword">public</span>: <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> } </pre> <p>This enables <i>Qt Designer</i> to use <a href="qobject.html#qobject_cast">qobject_cast</a>() to query for supported interfaces using nothing but a <a href="qobject.html">QObject</a> pointer.</p> <p>In <i>Qt Designer</i> the extensions are not created until they are required. For that reason, when implementing a property sheet extension, you must also create a <a href="qextensionfactory.html">QExtensionFactory</a>, i.e a class that is able to make an instance of your extension, and register it using <i>Qt Designer</i>'s <a href="qextensionmanager.html">extension manager</a>.</p> <p>When a property sheet extension is required, <i>Qt Designer</i>'s <a href="qextensionmanager.html">extension manager</a> will run through all its registered factories calling <a href="qextensionfactory.html#createExtension">QExtensionFactory.createExtension</a>() for each until the first one that is able to create a property sheet extension for the selected widget, is found. This factory will then make an instance of the extension. If no such factory can be found, <i>Qt Designer</i> will use the default property sheet.</p> <p>There are four available types of extensions in <i>Qt Designer</i>: <a href="qdesignercontainerextension.html">QDesignerContainerExtension</a>, <a href="qdesignermembersheetextension.html">QDesignerMemberSheetExtension</a>, QDesignerPropertySheetExtension and <a href="qdesignertaskmenuextension.html">QDesignerTaskMenuExtension</a>. Qt Designer's behavior is the same whether the requested extension is associated with a multi page container, a member sheet, a property sheet or a task menu.</p> <p>The <a href="qextensionfactory.html">QExtensionFactory</a> class provides a standard extension factory, and can also be used as an interface for custom extension factories. You can either create a new <a href="qextensionfactory.html">QExtensionFactory</a> and reimplement the <a href="qextensionfactory.html#createExtension">QExtensionFactory.createExtension</a>() function. For example:</p> <pre class="cpp"> <span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>ANewExtensionFactory<span class="operator">.</span>createExtension(<span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>object<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&</span>iid<span class="operator">,</span> <span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>parent) <span class="keyword">const</span> { <span class="keyword">if</span> (iid <span class="operator">!</span><span class="operator">=</span> Q_TYPEID(<span class="type">QDesignerPropertySheetExtension</span>)) <span class="keyword">return</span> <span class="number">0</span>; <span class="keyword">if</span> (MyCustomWidget <span class="operator">*</span>widget <span class="operator">=</span> qobject_cast<span class="operator"><</span>MyCustomWidget<span class="operator">*</span><span class="operator">></span> (object)) <span class="keyword">return</span> <span class="keyword">new</span> MyPropertySheetExtension(widget<span class="operator">,</span> parent); <span class="keyword">return</span> <span class="number">0</span>; } </pre> <p>Or you can use an existing factory, expanding the <a href="qextensionfactory.html#createExtension">QExtensionFactory.createExtension</a>() function to make the factory able to create a property sheet extension extension as well. For example:</p> <pre class="cpp"> <span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>AGeneralExtensionFactory<span class="operator">.</span>createExtension(<span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>object<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&</span>iid<span class="operator">,</span> <span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>parent) <span class="keyword">const</span> { MyCustomWidget <span class="operator">*</span>widget <span class="operator">=</span> qobject_cast<span class="operator"><</span>MyCustomWidget<span class="operator">*</span><span class="operator">></span>(object); <span class="keyword">if</span> (widget <span class="operator">&</span><span class="operator">&</span> (iid <span class="operator">=</span><span class="operator">=</span> Q_TYPEID(<span class="type"><a href="qdesignertaskmenuextension.html">QDesignerTaskMenuExtension</a></span>))) { <span class="keyword">return</span> <span class="keyword">new</span> MyTaskMenuExtension(widget<span class="operator">,</span> parent); } <span class="keyword">else</span> <span class="keyword">if</span> (widget <span class="operator">&</span><span class="operator">&</span> (iid <span class="operator">=</span><span class="operator">=</span> Q_TYPEID(<span class="type">QDesignerPropertySheetExtension</span>))) { <span class="keyword">return</span> <span class="keyword">new</span> MyPropertySheetExtension(widget<span class="operator">,</span> parent); } <span class="keyword">else</span> { <span class="keyword">return</span> <span class="number">0</span>; } } </pre> <p>For a complete example using an extension class, see the <a href="designer-taskmenuextension.html">Task Menu Extension example</a>. The example shows how to create a custom widget plugin for Qt Designer, and how to to use the <a href="qdesignertaskmenuextension.html">QDesignerTaskMenuExtension</a> class to add custom items to <i>Qt Designer</i>'s task menu.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDesignerPropertySheetExtension" />QDesignerPropertySheetExtension.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="QDesignerPropertySheetExtension-2" />QDesignerPropertySheetExtension.__init__ (<i>self</i>, <a href="qdesignerpropertysheetextension.html">QDesignerPropertySheetExtension</a>)</h3><h3 class="fn"><a name="count" />int QDesignerPropertySheetExtension.count (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the selected widget's number of properties.</p> <h3 class="fn"><a name="hasReset" />bool QDesignerPropertySheetExtension.hasReset (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns true if the property at the given <i>index</i> has a reset button in <i>Qt Designer</i>'s property editor, otherwise false.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>() and <a href="qdesignerpropertysheetextension.html#reset">reset</a>().</p> <h3 class="fn"><a name="indexOf" />int QDesignerPropertySheetExtension.indexOf (<i>self</i>, QString <i>name</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the index for a given property <i>name</i>.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#propertyName">propertyName</a>().</p> <h3 class="fn"><a name="isAttribute" />bool QDesignerPropertySheetExtension.isAttribute (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns true if the property at the given <i>index</i> is an attribute, which will be <i>excluded</i> from the UI file, otherwise false.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>() and <a href="qdesignerpropertysheetextension.html#setAttribute">setAttribute</a>().</p> <h3 class="fn"><a name="isChanged" />bool QDesignerPropertySheetExtension.isChanged (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns true if the value of the property at the given <i>index</i> differs from the property's default value, otherwise false.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>(), <a href="qdesignerpropertysheetextension.html#setChanged">setChanged</a>(), and <a href="qdesignerpropertysheetextension.html#reset">reset</a>().</p> <h3 class="fn"><a name="isVisible" />bool QDesignerPropertySheetExtension.isVisible (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns true if the property at the given <i>index</i> is visible in <i>Qt Designer</i>'s property editor, otherwise false.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>() and <a href="qdesignerpropertysheetextension.html#setVisible">setVisible</a>().</p> <h3 class="fn"><a name="property" />QVariant QDesignerPropertySheetExtension.property (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the value of the property at the given <i>index</i>.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>(), <a href="qdesignerpropertysheetextension.html#setProperty">setProperty</a>(), and <a href="qdesignerpropertysheetextension.html#propertyGroup">propertyGroup</a>().</p> <h3 class="fn"><a name="propertyGroup" />QString QDesignerPropertySheetExtension.propertyGroup (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the property group for the property at the given <i>index</i>.</p> <p><i>Qt Designer</i>'s property editor supports property groups, i.e. sections of related properties. A property can be related to a group using the <a href="qdesignerpropertysheetextension.html#setPropertyGroup">setPropertyGroup</a>() function. The default group of any property is the name of the class that defines it. For example, the <a href="qobject.html#objectName-prop">QObject.objectName</a> property appears within the <a href="qobject.html">QObject</a> property group.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>() and <a href="qdesignerpropertysheetextension.html#setPropertyGroup">setPropertyGroup</a>().</p> <h3 class="fn"><a name="propertyName" />QString QDesignerPropertySheetExtension.propertyName (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the name of the property at the given <i>index</i>.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>().</p> <h3 class="fn"><a name="reset" />bool QDesignerPropertySheetExtension.reset (<i>self</i>, int <i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Resets the value of the property at the given <i>index</i>, to the default value. Returns true if a default value could be found, otherwise false.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>(), <a href="qdesignerpropertysheetextension.html#hasReset">hasReset</a>(), and <a href="qdesignerpropertysheetextension.html#isChanged">isChanged</a>().</p> <h3 class="fn"><a name="setAttribute" />QDesignerPropertySheetExtension.setAttribute (<i>self</i>, int <i>index</i>, bool <i>b</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>If <i>attribute</i> is true, the property at the given <i>index</i> is made an attribute which will be <i>excluded</i> from the UI file; otherwise it will be included.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>() and <a href="qdesignerpropertysheetextension.html#isAttribute">isAttribute</a>().</p> <h3 class="fn"><a name="setChanged" />QDesignerPropertySheetExtension.setChanged (<i>self</i>, int <i>index</i>, bool <i>changed</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Sets whether the property at the given <i>index</i> is different from its default value, or not, depending on the <i>changed</i> parameter.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>() and <a href="qdesignerpropertysheetextension.html#isChanged">isChanged</a>().</p> <h3 class="fn"><a name="setProperty" />QDesignerPropertySheetExtension.setProperty (<i>self</i>, int <i>index</i>, QVariant <i>value</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Sets the <i>value</i> of the property at the given <i>index</i>.</p> <p><b>Warning:</b> If you change the value of a property using this function, the undo stack is not updated. To ensure that a property's value can be reverted using the undo stack, you must use the <a href="qdesignerformwindowcursorinterface.html#setProperty">QDesignerFormWindowCursorInterface.setProperty</a>() function, or its buddy <a href="qdesignerformwindowcursorinterface.html#setWidgetProperty">setWidgetProperty()</a>, instead.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>(), <a href="qdesignerpropertysheetextension.html#property">property</a>(), and <a href="qdesignerpropertysheetextension.html#propertyGroup">propertyGroup</a>().</p> <h3 class="fn"><a name="setPropertyGroup" />QDesignerPropertySheetExtension.setPropertyGroup (<i>self</i>, int <i>index</i>, QString <i>group</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Sets the property group for the property at the given <i>index</i> to <i>group</i>.</p> <p>Relating a property to a group makes it appear within that group's section in the property editor. The default property group of any property is the name of the class that defines it. For example, the <a href="qobject.html#objectName-prop">QObject.objectName</a> property appears within the <a href="qobject.html">QObject</a> property group.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>(), <a href="qdesignerpropertysheetextension.html#property">property</a>(), and <a href="qdesignerpropertysheetextension.html#propertyGroup">propertyGroup</a>().</p> <h3 class="fn"><a name="setVisible" />QDesignerPropertySheetExtension.setVisible (<i>self</i>, int <i>index</i>, bool <i>b</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>If <i>visible</i> is true, the property at the given <i>index</i> is visible in <i>Qt Designer</i>'s property editor; otherwise the property is hidden.</p> <p><b>See also</b> <a href="qdesignerpropertysheetextension.html#indexOf">indexOf</a>() and <a href="qdesignerpropertysheetextension.html#isVisible">isVisible</a>().</p> <h3 class="fn"><a name="__len__" /> QDesignerPropertySheetExtension.__len__ (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>