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规定,通常用于查询窗口小部件的属性,操纵性能“出现在属性编辑器的功能的集合。例如:
QDesignerPropertySheetExtension *propertySheet = 0;
[QExtensionManager]($docs-qextensionmanager.html) manager = formEditor->extensionManager();
propertySheet = qt_extension<QDesignerPropertySheetExtension*>(manager, widget);
int index = propertySheet->indexOf(QLatin1String("margin"));
propertySheet->setProperty(index, 10);
propertySheet->setChanged(index, true);
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()宏:
class MyPropertySheetExtension : public [QObject]($docs-qobject.html),
public QDesignerPropertySheetExtension
{
Q_OBJECT
Q_INTERFACES(QDesignerPropertySheetExtension)
public:
...
}
这使Qt Designer使用qobject_cast()来查询只是用一个接口支持QObject指针。
In Qt Designer未创建的扩展,直到你需要它们。出于这个原因,实现属性表扩展时,您还必须创建一个QExtensionFactory,即一个类,它能够让你的扩展的一个实例,并使用它注册Qt Designer的extension manager。
当一个属性表扩展是必需的,Qt Designer的extension manager将通过其所有已注册的工厂运行要求QExtensionFactory.createExtension( )对每一直到第一个是能够创造一个属性表扩展选定控件,被找到。这家工厂将使这个扩展的实例。如果没有这样的工厂,可以发现,Qt Designer将使用默认的属性表。
有扩展的四个可用的类型Qt Designer:QDesignerContainerExtension,QDesignerMemberSheetExtension, QDesignerPropertySheetExtension和QDesignerTaskMenuExtension。 Qt设计器的行为是一样的具有多页的容器,一个成员表,属性表或任务菜单中的延期申请是否相关。
该QExtensionFactory类提供了一个标准的扩展工厂,并且也可以用作用于定义扩展工厂的接口。您可以创建一个新的QExtensionFactory并重新实现QExtensionFactory.createExtension()函数。例如:
[QObject]($docs-qobject.html) *ANewExtensionFactory.createExtension([QObject]($docs-qobject.html) *object,
const [QString](qstring.html) &iid, [QObject]($docs-qobject.html) *parent) const
{
if (iid != Q_TYPEID(QDesignerPropertySheetExtension))
return 0;
if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
(object))
return new MyPropertySheetExtension(widget, parent);
return 0;
}
或者您可以使用现有的工厂,扩大QExtensionFactory.createExtension( )函数,使工厂能够创建一个属性表扩展延伸为好。例如:
[QObject]($docs-qobject.html) *AGeneralExtensionFactory.createExtension([QObject]($docs-qobject.html) *object,
const [QString](qstring.html) &iid, [QObject]($docs-qobject.html) *parent) const
{
MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
if (widget && (iid == Q_TYPEID([QDesignerTaskMenuExtension]($docs-qdesignertaskmenuextension.html)))) {
return new MyTaskMenuExtension(widget, parent);
} else if (widget && (iid == Q_TYPEID(QDesignerPropertySheetExtension))) {
return new MyPropertySheetExtension(widget, parent);
} else {
return 0;
}
}
对于使用扩展类的完整示例,请参见Task Menu Extension example。该示例显示了如何创建一个自定义的widget插件Qt Designer中,以及如何使用QDesignerTaskMenuExtension类的自定义项添加到Qt Designer的任务菜单。
Method Documentation
QDesignerPropertySheetExtension.__init__ (self)
QDesignerPropertySheetExtension.__init__ (self, QDesignerPropertySheetExtension)
int QDesignerPropertySheetExtension.count (self)
这种方法是抽象的,应在任何子类中重新实现。
返回的属性所选部件的数量。
bool QDesignerPropertySheetExtension.hasReset (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
返回True如果给定的酒店在index有一个复位按钮Qt Designer的属性编辑器,否则为False 。
int QDesignerPropertySheetExtension.indexOf (self, QString name)
这种方法是抽象的,应在任何子类中重新实现。
返回索引对于给定的属性name。
See also propertyName( ) 。
bool QDesignerPropertySheetExtension.isAttribute (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
返回True如果给定的酒店在index是一个属性,这将是excluded从UI文件,否则为False。
See also indexOf()和setAttribute( ) 。
bool QDesignerPropertySheetExtension.isChanged (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
返回True如果给定的属性的值index不同于属性的默认值,否则返回False 。
See also indexOf( )setChanged()和reset( ) 。
bool QDesignerPropertySheetExtension.isVisible (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
返回True如果给定的酒店在index在可见Qt Designer的属性编辑器,否则为False 。
See also indexOf()和setVisible( ) 。
QVariant QDesignerPropertySheetExtension.property (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
在给定的返回属性的值index。
See also indexOf( )setProperty()和propertyGroup( ) 。
QString QDesignerPropertySheetExtension.propertyGroup (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
在给定的返回属性组属性index。
Qt Designer的属性编辑器支持属性组,相关性,即部分。一个属性可以使用上与一组setPropertyGroup()函数。任何属性的默认组是定义它的类的名称。例如,本QObject.objectName物业内出现的QObject属性组。
See also indexOf()和setPropertyGroup( ) 。
QString QDesignerPropertySheetExtension.propertyName (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
返回属性的名称在给定的index。
See also indexOf( ) 。
bool QDesignerPropertySheetExtension.reset (self, int index)
这种方法是抽象的,应在任何子类中重新实现。
复位在给定的属性的值index,为默认值。返回True如果默认值可以发现,否则为False 。
See also indexOf( )hasReset()和isChanged( ) 。
QDesignerPropertySheetExtension.setAttribute (self, int index, bool b)
这种方法是抽象的,应在任何子类中重新实现。
If attribute诚然,该物业在给定的index由这将是一个属性excluded从UI文件,否则将被纳入。
See also indexOf()和isAttribute( ) 。
QDesignerPropertySheetExtension.setChanged (self, int index, bool changed)
这种方法是抽象的,应在任何子类中重新实现。
设置该属性是否在给定的index从它的默认值,或没有,根据不同的changed参数。
See also indexOf()和isChanged( ) 。
QDesignerPropertySheetExtension.setProperty (self, int index, QVariant value)
这种方法是抽象的,应在任何子类中重新实现。
设置value酒店在给定的index。
Warning:如果更改使用此功能的属性的值,撤消堆栈没有更新。为了确保一个属性的值可以使用撤消堆栈被还原,则必须使用QDesignerFormWindowCursorInterface.setProperty( )函数,或者它的夥伴setWidgetProperty()代替。
See also indexOf( )property()和propertyGroup( ) 。
QDesignerPropertySheetExtension.setPropertyGroup (self, int index, QString group)
这种方法是抽象的,应在任何子类中重新实现。
设置属性组的属性在给定index至group。
有关物业为一组使得在属性编辑器该组的部分中也出现。默认属性组中的任何财产是定义它的类的名称。例如,本QObject.objectName物业内出现的QObject属性组。
See also indexOf( )property()和propertyGroup( ) 。
QDesignerPropertySheetExtension.setVisible (self, int index, bool b)
这种方法是抽象的,应在任何子类中重新实现。
If visible诚然,该物业在给定的index在可见Qt Designer的属性编辑器,否则该属性是隐藏的。
See also indexOf()和isVisible( ) 。
QDesignerPropertySheetExtension.__len__ (self)