QDesignerPropertySheetExtension Class Reference

[QtDesigner module]

该QDesignerPropertySheetExtension类允许你操作并显示在Qt设计器的属性编辑器窗口小部件的属性。More…

通过继承QPyDesignerPropertySheetExtension

Methods

  • __init__ (self)
  • __init__ (self, QDesignerPropertySheetExtension)
  • int count (self)
  • bool hasReset (self, int index)
  • int indexOf (self, QString name)
  • bool isAttribute (self, int index)
  • bool isChanged (self, int index)
  • bool isVisible (self, int index)
  • QVariant property (self, int index)
  • QString propertyGroup (self, int index)
  • QString propertyName (self, int index)
  • bool reset (self, int index)
  • setAttribute (self, int index, bool b)
  • setChanged (self, int index, bool changed)
  • setProperty (self, int index, QVariant value)
  • setPropertyGroup (self, int index, QString group)
  • setVisible (self, int index, bool b)

Special Methods

  • __len__ (self)

Detailed Description

该QDesignerPropertySheetExtension类允许你操作并显示在Qt设计器的属性编辑器窗口小部件的属性。

QDesignerPropertySheetExtension规定,通常用于查询窗口小部件的属性,操纵性能“出现在属性编辑器的功能的集合。例如:

  1. QDesignerPropertySheetExtension *propertySheet = 0;
  2. [QExtensionManager]($docs-qextensionmanager.html) manager = formEditor->extensionManager();
  3. propertySheet = qt_extension<QDesignerPropertySheetExtension*>(manager, widget);
  4. int index = propertySheet->indexOf(QLatin1String("margin"));
  5. propertySheet->setProperty(index, 10);
  6. propertySheet->setChanged(index, true);
  7. delete propertySheet;

请注意,如果您使用更改属性的值QDesignerPropertySheetExtension.setProperty( )函数,撤消堆栈没有更新。为了确保一个属性的值可以使用撤消堆栈被还原,则必须使用QDesignerFormWindowCursorInterface.setProperty( )函数,或者它的夥伴setWidgetProperty()代替。

当实现一个自定义的widget插件,一个指向Qt Designer目前的QDesignerFormEditorInterface对象(formEditor在上面的例子)是由提供QDesignerCustomWidgetInterface.initialize( )函数的参数。

属性表,或任何其他分机,可以通过查询检索Qt Designer使用的扩展管理器qt_extension()函数。当你要释放的扩展,你只需要删除的指针。

所有的部件都有一个默认的属性表的填充Qt Designer的属性编辑器的控件的属性(即与所定义的那些Q_PROPERTY()宏) 。但QDesignerPropertySheetExtension还提供了用于创建自定义属性表扩展的接口。

Warning: Qt Designer使用QDesignerPropertySheetExtension养活它的属性编辑器。每当一个小部件中选择其工作区,Qt Designer将查询窗口小部件的属性表扩展。如果选定部件有一个实现属性表的扩展,这个扩展将复盖默认的属性表。

要创建一个属性表的扩展,你的扩展类必须继承自两个QObject和QDesignerPropertySheetExtension 。然后,因为我们正在实现一个接口,我们必须确保它是由已知的元对象系统中使用Q_INTERFACES()宏:

  1. class MyPropertySheetExtension : public [QObject]($docs-qobject.html),
  2. public QDesignerPropertySheetExtension
  3. {
  4. Q_OBJECT
  5. Q_INTERFACES(QDesignerPropertySheetExtension)
  6. public:
  7. ...
  8. }

这使Qt Designer使用qobject_cast()来查询只是用一个接口支持QObject指针。

In Qt Designer未创建的扩展,直到你需要它们。出于这个原因,实现属性表扩展时,您还必须创建一个QExtensionFactory,即一个类,它能够让你的扩展的一个实例,并使用它注册Qt Designerextension manager

当一个属性表扩展是必需的,Qt Designerextension manager将通过其所有已注册的工厂运行要求QExtensionFactory.createExtension( )对每一直到第一个是能够创造一个属性表扩展选定控件,被找到。这家工厂将使这个扩展的实例。如果没有这样的工厂,可以发现,Qt Designer将使用默认的属性表。

有扩展的四个可用的类型Qt DesignerQDesignerContainerExtensionQDesignerMemberSheetExtension, QDesignerPropertySheetExtension和QDesignerTaskMenuExtension。 Qt设计器的行为是一样的具有多页的容器,一个成员表,属性表或任务菜单中的延期申请是否相关。

QExtensionFactory类提供了一个标准的扩展工厂,并且也可以用作用于定义扩展工厂的接口。您可以创建一个新的QExtensionFactory并重新实现QExtensionFactory.createExtension()函数。例如:

  1. [QObject]($docs-qobject.html) *ANewExtensionFactory.createExtension([QObject]($docs-qobject.html) *object,
  2. const [QString](qstring.html) &iid, [QObject]($docs-qobject.html) *parent) const
  3. {
  4. if (iid != Q_TYPEID(QDesignerPropertySheetExtension))
  5. return 0;
  6. if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
  7. (object))
  8. return new MyPropertySheetExtension(widget, parent);
  9. return 0;
  10. }

或者您可以使用现有的工厂,扩大QExtensionFactory.createExtension( )函数,使工厂能够创建一个属性表扩展延伸为好。例如:

  1. [QObject]($docs-qobject.html) *AGeneralExtensionFactory.createExtension([QObject]($docs-qobject.html) *object,
  2. const [QString](qstring.html) &iid, [QObject]($docs-qobject.html) *parent) const
  3. {
  4. MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
  5. if (widget && (iid == Q_TYPEID([QDesignerTaskMenuExtension]($docs-qdesignertaskmenuextension.html)))) {
  6. return new MyTaskMenuExtension(widget, parent);
  7. } else if (widget && (iid == Q_TYPEID(QDesignerPropertySheetExtension))) {
  8. return new MyPropertySheetExtension(widget, parent);
  9. } else {
  10. return 0;
  11. }
  12. }

对于使用扩展类的完整示例,请参见Task Menu Extension example。该示例显示了如何创建一个自定义的widget插件Qt Designer中,以及如何使用QDesignerTaskMenuExtension类的自定义项添加到Qt Designer的任务菜单。


Method Documentation

  1. QDesignerPropertySheetExtension.__init__ (self)
  1. QDesignerPropertySheetExtension.__init__ (self, QDesignerPropertySheetExtension)
  1. int QDesignerPropertySheetExtension.count (self)

这种方法是抽象的,应在任何子类中重新实现。

返回的属性所选部件的数量。

  1. bool QDesignerPropertySheetExtension.hasReset (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

返回True如果给定的酒店在index有一个复位按钮Qt Designer的属性编辑器,否则为False 。

See also indexOf()和reset( ) 。

  1. int QDesignerPropertySheetExtension.indexOf (self, QString name)

这种方法是抽象的,应在任何子类中重新实现。

返回索引对于给定的属性name

See also propertyName( ) 。

  1. bool QDesignerPropertySheetExtension.isAttribute (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

返回True如果给定的酒店在index是一个属性,这将是excluded从UI文件,否则为False。

See also indexOf()和setAttribute( ) 。

  1. bool QDesignerPropertySheetExtension.isChanged (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

返回True如果给定的属性的值index不同于属性的默认值,否则返回False 。

See also indexOf( )setChanged()和reset( ) 。

  1. bool QDesignerPropertySheetExtension.isVisible (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

返回True如果给定的酒店在index在可见Qt Designer的属性编辑器,否则为False 。

See also indexOf()和setVisible( ) 。

  1. QVariant QDesignerPropertySheetExtension.property (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

在给定的返回属性的值index

See also indexOf( )setProperty()和propertyGroup( ) 。

  1. QString QDesignerPropertySheetExtension.propertyGroup (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

在给定的返回属性组属性index

Qt Designer的属性编辑器支持属性组,相关性,即部分。一个属性可以使用上与一组setPropertyGroup()函数。任何属性的默认组是定义它的类的名称。例如,本QObject.objectName物业内出现的QObject属性组。

See also indexOf()和setPropertyGroup( ) 。

  1. QString QDesignerPropertySheetExtension.propertyName (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

返回属性的名称在给定的index

See also indexOf( ) 。

  1. bool QDesignerPropertySheetExtension.reset (self, int index)

这种方法是抽象的,应在任何子类中重新实现。

复位在给定的属性的值index,为默认值。返回True如果默认值可以发现,否则为False 。

See also indexOf( )hasReset()和isChanged( ) 。

  1. QDesignerPropertySheetExtension.setAttribute (self, int index, bool b)

这种方法是抽象的,应在任何子类中重新实现。

If attribute诚然,该物业在给定的index由这将是一个属性excluded从UI文件,否则将被纳入。

See also indexOf()和isAttribute( ) 。

  1. QDesignerPropertySheetExtension.setChanged (self, int index, bool changed)

这种方法是抽象的,应在任何子类中重新实现。

设置该属性是否在给定的index从它的默认值,或没有,根据不同的changed参数。

See also indexOf()和isChanged( ) 。

  1. QDesignerPropertySheetExtension.setProperty (self, int index, QVariant value)

这种方法是抽象的,应在任何子类中重新实现。

设置value酒店在给定的index

Warning:如果更改使用此功能的属性的值,撤消堆栈没有更新。为了确保一个属性的值可以使用撤消堆栈被还原,则必须使用QDesignerFormWindowCursorInterface.setProperty( )函数,或者它的夥伴setWidgetProperty()代替。

See also indexOf( )property()和propertyGroup( ) 。

  1. QDesignerPropertySheetExtension.setPropertyGroup (self, int index, QString group)

这种方法是抽象的,应在任何子类中重新实现。

设置属性组的属性在给定indexgroup

有关物业为一组使得在属性编辑器该组的部分中也出现。默认属性组中的任何财产是定义它的类的名称。例如,本QObject.objectName物业内出现的QObject属性组。

See also indexOf( )property()和propertyGroup( ) 。

  1. QDesignerPropertySheetExtension.setVisible (self, int index, bool b)

这种方法是抽象的,应在任何子类中重新实现。

If visible诚然,该物业在给定的index在可见Qt Designer的属性编辑器,否则该属性是隐藏的。

See also indexOf()和isVisible( ) 。

  1. QDesignerPropertySheetExtension.__len__ (self)