QDesignerPropertyEditorInterface Class Reference
[QtDesigner module]
该QDesignerPropertyEditorInterface类允许你查询和操作的Qt设计器的属性编辑器的当前状态。More…
继承QWidget。
Methods
__init__ (self, QWidget parent, Qt.WindowFlags flags = 0)
QDesignerFormEditorInterface core (self)
QString currentPropertyName (self)
bool isReadOnly (self)
QObject object (self)
setObject (self, QObject object)
setPropertyValue (self, QString name, QVariant value, bool changed = True)
setReadOnly (self, bool readOnly)
Qt Signals
void propertyChanged (const QString&,const QVariant&)
Detailed Description
该QDesignerPropertyEditorInterface类允许你查询和操作的Qt设计器的属性编辑器的当前状态。
QDesignerPropertyEditorInterface包含了通常用于查询的属性编辑器,其当前状态的功能,和几个插槽集合操纵它的状态。该接口还提供了一个信号,propertyChanged( ) ,这是发射时在属性编辑器中的属性更改。该信号的参数是已更改的属性及其新值。
例如,实现一个自定义的widget插件时,你可以将信号连接到一个自定义的槽:
QDesignerPropertyEditorInterface *propertyEditor = 0;
propertyEditor = formEditor->propertyEditor();
connect(propertyEditor, SIGNAL(propertyChanged([QString](qstring.html), [QVariant](qvariant.html))),
this, SLOT(checkProperty([QString](qstring.html), [QVariant](qvariant.html))));
此外,定制的插槽可以检查新值,我们希望在一个指定的属性,属于特定窗口小部件,改变的范围之内:
void checkProperty([QString](qstring.html) property, [QVariant](qvariant.html) value) {
QDesignerPropertyEditorInterface *propertyEditor = 0;
propertyEditor = formEditor->propertyEditor();
[QObject]($docs-qobject.html) *object = propertyeditor->object();
MyCustomWidget *widget = qobject_cast<MyCustomWidget>(object);
if (widget && property == aProperty && value != expectedValue)
{...}
}
该QDesignerPropertyEditorInterface类不适合直接实例化。你可以检索界面Qt Designer使用的属性编辑器QDesignerFormEditorInterface.propertyEditor()函数。一个指向Qt Designer目前的QDesignerFormEditorInterface对象(formEditor
在上面的例子)是由提供QDesignerCustomWidgetInterface.initialize( )函数的参数。当实现一个自定义的widget插件,你必须在子类QDesignerCustomWidgetInterface暴露你的插件Qt Designer。
访问属性编辑器的功能是core( )函数,你可以使用它来检索一个接口,表单编辑器中,currentPropertyName( )函数,返回的属性编辑器中当前所选属性的名称时,object( )函数,返回当前选定的对象Qt Designer的工作空间,以及isReadOnly( )函数,如果属性编辑器是写proteced返回True (否则返回False ) 。
操纵属性编辑器的状态的槽的setObject()槽,你可以用它来改变当前选定的对象Qt Designer的工作区时,setPropertyValue()槽,改变一个给定属性的值和setReadOnly()槽控制的属性编辑器的写保护。
Method Documentation
QDesignerPropertyEditorInterface.__init__ (self, QWidget parent, Qt.WindowFlags flags = 0)
该parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。
构造一个属性编辑器界面与给定parent和在指定的窗口flags。
QDesignerFormEditorInterface QDesignerPropertyEditorInterface.core (self)
返回一个指针Qt Designer目前的QDesignerFormEditorInterface对象。
QString QDesignerPropertyEditorInterface.currentPropertyName (self)
这种方法是抽象的,应在任何子类中重新实现。
返回在属性编辑器中当前所选属性的名称。
See also setPropertyValue( ) 。
bool QDesignerPropertyEditorInterface.isReadOnly (self)
这种方法是抽象的,应在任何子类中重新实现。
返回True,如果属性编辑器处于写保护状态,否则为False 。
See also setReadOnly( ) 。
QObject QDesignerPropertyEditorInterface.object (self)
[
这种方法是抽象的,应在任何子类中重新实现。
返回当前选定的对象Qt Designer的工作空间。
]($docs-qobject.html)
QDesignerPropertyEditorInterface.setObject (self, QObject object)
这种方法也是一个Qt槽与C + +的签名void setObject(QObject *)
。
这种方法是抽象的,应在任何子类中重新实现。
在更改当前选定的对象Qt Designer的工作空间,以object。
See also object( ) 。
QDesignerPropertyEditorInterface.setPropertyValue (self, QString name, QVariant value, bool changed = True)
这种方法也是一个Qt槽与C + +的签名void setPropertyValue(const QString&,const QVariant&,bool = 1)
。
这种方法是抽象的,应在任何子类中重新实现。
通过设置指定的属性值name至value。
此外,该属性标记为changed在属性编辑器,即它的值从默认值不同。
See also currentPropertyName()和propertyChanged( ) 。
QDesignerPropertyEditorInterface.setReadOnly (self, bool readOnly)
这种方法也是一个Qt槽与C + +的签名void setReadOnly(bool)
。
这种方法是抽象的,应在任何子类中重新实现。
If readOnly为True,则属性编辑器是由写保护,否则写保护被删除。
See also isReadOnly( ) 。
Qt Signal Documentation
void propertyChanged (const QString&,const QVariant&)
这是该信号的默认超载。
这个信号被发射时在属性编辑器中的属性更改。这改变了其新的价值的财产被指定name和value分别。
See also setPropertyValue( ) 。