内容表

上一话题

QQmlParserStatus

下一话题

QQmlPropertyMap

QQmlProperty

QQmlProperty class abstracts accessing properties on objects created from QML. 更多

Inheritance diagram of PySide2.QtQml.QQmlProperty

概要

静态函数

  • def read (arg__1, arg__2)

  • def read (arg__1, arg__2, arg__3)

  • def read (arg__1, arg__2, arg__3)

  • def write (arg__1, arg__2, arg__3)

  • def write (arg__1, arg__2, arg__3, arg__4)

  • def write (arg__1, arg__2, arg__3, arg__4)

详细描述

As QML uses Qt’s meta-type system all of the existing QMetaObject classes can be used to introspect and interact with objects created by QML. However, some of the new features provided by QML - such as type safety and attached properties - are most easily used through the QQmlProperty class that simplifies some of their natural complexity.

不像 QMetaProperty which represents a property on a class type, QQmlProperty encapsulates a property on a specific object instance. To read a property’s value, programmers create a QQmlProperty instance and call the read() method. Likewise to write a property value the write() method is used.

For example, for the following QML code:

文本 object’s properties could be accessed using QQmlProperty , like this:

#include <QQmlProperty>
#include <QGraphicsObject>
...
QQuickView view(QUrl::fromLocalFile("MyItem.qml"));
QQmlProperty property(view.rootObject(), "font.pixelSize");
qWarning() << "Current pixel size:" << property.read().toInt();
property.write(24);
qWarning() << "Pixel size should now be 24:" << property.read().toInt();
											
class QQmlProperty

QQmlProperty(arg__1)

QQmlProperty(arg__1, arg__2)

QQmlProperty(arg__1, arg__2)

QQmlProperty(arg__1, arg__2)

QQmlProperty(arg__1, arg__2, arg__3)

QQmlProperty(arg__1, arg__2, arg__3)

QQmlProperty(arg__1)

param arg__1

QObject

param arg__2

QQmlContext

param arg__3

QQmlContext

Create an invalid QQmlProperty .

创建 QQmlProperty for the default property of obj . If there is no default property, an invalid QQmlProperty will be created.

创建 QQmlProperty for the default property of obj 使用 context ctxt . If there is no default property, an invalid QQmlProperty will be created.

创建 QQmlProperty for the default property of obj using the environment for instantiating QML components that is provided by engine . If there is no default property, an invalid QQmlProperty will be created.

PySide2.QtQml.QQmlProperty. PropertyTypeCategory

This enum specifies a category of QML property.

常量

描述

QQmlProperty.InvalidCategory

The property is invalid, or is a signal property.

QQmlProperty.List

The property is a QQmlListProperty list property

QQmlProperty.Object

The property is a QObject derived type pointer

QQmlProperty.Normal

The property is a normal value property.

PySide2.QtQml.QQmlProperty. Type

This enum specifies a type of QML property.

常量

描述

QQmlProperty.Invalid

The property is invalid.

QQmlProperty.Property

The property is a regular Qt property.

QQmlProperty.SignalProperty

The property is a signal property.

PySide2.QtQml.QQmlProperty. connectNotifySignal ( dest , slot )
参数
  • dest QObject

  • slot – str

返回类型

bool

Connects the property’s change notifier signal to the specified slot dest object and returns true. Returns false if this metaproperty does not represent a regular Qt property or if it has no change notifier signal, or if the dest object does not have the specified slot .

注意

slot should be passed using the SLOT() macro so it is correctly identified.

PySide2.QtQml.QQmlProperty. connectNotifySignal ( dest , 方法 )
参数
  • dest QObject

  • 方法 int

返回类型

bool

Connects the property’s change notifier signal to the specified 方法 dest object and returns true. Returns false if this metaproperty does not represent a regular Qt property or if it has no change notifier signal, or if the dest object does not have the specified 方法 .

PySide2.QtQml.QQmlProperty. hasNotifySignal ( )
返回类型

bool

Returns true if the property has a change notifier signal, otherwise false.

PySide2.QtQml.QQmlProperty. index ( )
返回类型

int

Return the Qt metaobject index of the property.

PySide2.QtQml.QQmlProperty. isDesignable ( )
返回类型

bool

Returns true if the property is designable, otherwise false.

PySide2.QtQml.QQmlProperty. isProperty ( )
返回类型

bool

返回 true,若此 QQmlProperty represents a regular Qt property.

PySide2.QtQml.QQmlProperty. isResettable ( )
返回类型

bool

Returns true if the property is resettable, otherwise false.

PySide2.QtQml.QQmlProperty. isSignalProperty ( )
返回类型

bool

返回 true,若此 QQmlProperty represents a QML signal property.

PySide2.QtQml.QQmlProperty. isValid ( )
返回类型

bool

返回 true 若 QQmlProperty refers to a valid property, otherwise false.

PySide2.QtQml.QQmlProperty. isWritable ( )
返回类型

bool

Returns true if the property is writable, otherwise false.

PySide2.QtQml.QQmlProperty. 方法 ( )
返回类型

QMetaMethod

返回 QMetaMethod for this property if it is a SignalProperty , otherwise returns an invalid QMetaMethod .

PySide2.QtQml.QQmlProperty. name ( )
返回类型

unicode

Return the name of this QML property.

PySide2.QtQml.QQmlProperty. needsNotifySignal ( )
返回类型

bool

Returns true if the property needs a change notifier signal for bindings to remain upto date, false otherwise.

Some properties, such as attached properties or those whose value never changes, do not require a change notifier.

PySide2.QtQml.QQmlProperty. object ( )
返回类型

QObject

返回 QQmlProperty ‘s QObject .

PySide2.QtQml.QQmlProperty. __eq__ ( arg__1 )
参数

arg__1 QQmlProperty

返回类型

bool

返回 true 若 other 和此 QQmlProperty represent the same property.

PySide2.QtQml.QQmlProperty. 特性 ( )
返回类型

QMetaProperty

返回 Qt 特性 associated with this QML property.

PySide2.QtQml.QQmlProperty. propertyType ( )
返回类型

int

返回 QVariant type of the property, or Invalid if the property has no QVariant 类型。

PySide2.QtQml.QQmlProperty. propertyTypeCategory ( )
返回类型

PropertyTypeCategory

Returns the property category.

PySide2.QtQml.QQmlProperty. propertyTypeName ( )
返回类型

str

Returns the type name of the property, or 0 if the property has no type name.

static PySide2.QtQml.QQmlProperty. read ( arg__1 , arg__2 )
参数
  • arg__1 QObject

  • arg__2 – unicode

返回类型

object

返回 name property value of object . This method is equivalent to:

QQmlProperty p(object, name);
p.read();
											
static PySide2.QtQml.QQmlProperty. read ( arg__1 , arg__2 , arg__3 )
参数
  • arg__1 QObject

  • arg__2 – unicode

  • arg__3 QQmlEngine

返回类型

object

static PySide2.QtQml.QQmlProperty. read ( arg__1 , arg__2 , arg__3 )
参数
返回类型

object

PySide2.QtQml.QQmlProperty. read ( )
返回类型

object

Returns the property value.

PySide2.QtQml.QQmlProperty. reset ( )
返回类型

bool

Resets the property and returns true if the property is resettable. If the property is not resettable, nothing happens and false is returned.

PySide2.QtQml.QQmlProperty. type ( )
返回类型

Type

Returns the type of the property.

static PySide2.QtQml.QQmlProperty. write ( arg__1 , arg__2 , arg__3 )
参数
  • arg__1 QObject

  • arg__2 – unicode

  • arg__3 – object

返回类型

bool

写入 value name property of object . This method is equivalent to:

QQmlProperty p(object, name);
p.write(value);
											

返回 true 当成功时, false 否则。

static PySide2.QtQml.QQmlProperty. write ( arg__1 , arg__2 , arg__3 , arg__4 )
参数
  • arg__1 QObject

  • arg__2 – unicode

  • arg__3 – object

  • arg__4 QQmlContext

返回类型

bool

static PySide2.QtQml.QQmlProperty. write ( arg__1 , arg__2 , arg__3 , arg__4 )
参数
  • arg__1 QObject

  • arg__2 – unicode

  • arg__3 – object

  • arg__4 QQmlEngine

返回类型

bool

PySide2.QtQml.QQmlProperty. write ( arg__1 )
参数

arg__1 – object

返回类型

bool

Sets the property value to value 。返回 true on success, or false if the property can’t be set because the value is the wrong type, for example.