QDeclarativeProperty Class Reference

[QtDeclarative module]

该QDeclarativeProperty类文摘从QML创建的对象访问属性。More…

Types

  • enum PropertyTypeCategory { InvalidCategory, List, Object, Normal }
  • enum Type { Invalid, Property, SignalProperty }

Methods

  • __init__ (self)
  • __init__ (self, QObject)
  • __init__ (self, QObject, QDeclarativeContext)
  • __init__ (self, QObject, QDeclarativeEngine)
  • __init__ (self, QObject, QString)
  • __init__ (self, QObject, QString, QDeclarativeContext)
  • __init__ (self, QObject, QString, QDeclarativeEngine)
  • __init__ (self, QDeclarativeProperty)
  • bool connectNotifySignal (self, QObject dest, SLOT()SLOT() slot)
  • bool connectNotifySignal (self, callable dest)
  • bool connectNotifySignal (self, QObject dest, int method)
  • bool hasNotifySignal (self)
  • int index (self)
  • bool isDesignable (self)
  • bool isProperty (self)
  • bool isResettable (self)
  • bool isSignalProperty (self)
  • bool isValid (self)
  • bool isWritable (self)
  • QMetaMethod method (self)
  • QString name (self)
  • bool needsNotifySignal (self)
  • QObject object (self)
  • QMetaProperty property (self)
  • int propertyType (self)
  • PropertyTypeCategory propertyTypeCategory (self)
  • str propertyTypeName (self)
  • QVariant read (self)
  • bool reset (self)
  • Type type (self)
  • bool write (self, QVariant)

Static Methods

  • QVariant read (QObject, QString)
  • QVariant read (QObject, QString, QDeclarativeContext)
  • QVariant read (QObject, QString, QDeclarativeEngine)
  • bool write (QObject, QString, QVariant)
  • bool write (QObject, QString, QVariant, QDeclarativeContext)
  • bool write (QObject, QString, QVariant, QDeclarativeEngine)

Special Methods

  • bool __eq__ (self, QDeclarativeProperty)
  • int __hash__ (self)
  • bool __ne__ (self, QDeclarativeProperty)

Detailed Description

该QDeclarativeProperty类文摘从QML创建的对象访问属性。

由于QML使用Qt的元类型系统中所有现有的QMetaObject类可以用来反思,并与QML创建的对象进行交互。然而,一些通过QML提供的新功能 - 如类型安全和附加属性 - 是最容易通过简化他们的一些自然的复杂性QDeclarativeProperty类中使用。

不像QMetaProperty它代表一个类类型的属性, QDeclarativeProperty封装在一个特定的对象实例的属性。要读取一个属性值,程序员创建一个QDeclarativeProperty实例,并调用read()方法。同样写一个属性值write()方法被使用。

例如,对于下面的QML代码:

  1. // MyItem.qml
  2. import QtQuick 1.0
  3. [Text]($docs-index.htm) { text: "A bit of text" }

Text对象的属性可以用QDeclarativeProperty进行访问,如下所示:

  1. #include <QDeclarativeProperty>
  2. #include <QGraphicsObject>
  3. ...
  4. [QDeclarativeView](qdeclarativeview.html) view([QUrl](qurl.html).fromLocalFile("MyItem.qml"));
  5. QDeclarativeProperty property(view.rootObject(), "font.pixelSize");
  6. qWarning() << "Current pixel size:" << property.read().toInt();
  7. property.write(24);
  8. qWarning() << "Pixel size should now be 24:" << property.read().toInt();

Type Documentation

  1. QDeclarativeProperty.PropertyTypeCategory

此枚举指定一个类别的QML属性。

Constant Value Description
QDeclarativeProperty.InvalidCategory 0 该属性是无效的,或者是一个信号特性。
QDeclarativeProperty.List 1 该属性是一个QDeclarativeListProperty列表属性
QDeclarativeProperty.Object 2 该属性是一个QObject派生类型的指针
QDeclarativeProperty.Normal 3 该属性是一个正常的值属性。
  1. QDeclarativeProperty.Type

此枚举指定类型QML属性。

Constant Value Description
QDeclarativeProperty.Invalid 0 该属性无效。
QDeclarativeProperty.Property 1 该属性是一个普通的Qt属性。
QDeclarativeProperty.SignalProperty 2 该属性是一个信号特性。

Method Documentation

  1. QDeclarativeProperty.__init__ (self)

创建一个无效的QDeclarativeProperty

  1. QDeclarativeProperty.__init__ (self, QObject)

创建QDeclarativeProperty为默认属性obj。如果没有默认属性,无效QDeclarativeProperty将被创建。

  1. QDeclarativeProperty.__init__ (self, QObject, QDeclarativeContext)

创建QDeclarativeProperty为默认属性obj使用context ctxt。如果没有默认属性,无效QDeclarativeProperty将被创建。

  1. QDeclarativeProperty.__init__ (self, QObject, QDeclarativeEngine)

创建QDeclarativeProperty为默认属性obj使用环境的实例,是由提供的QML组件engine。如果没有默认属性,无效QDeclarativeProperty将被创建。

  1. QDeclarativeProperty.__init__ (self, QObject, QString)

创建QDeclarativeProperty该物业nameobj

  1. QDeclarativeProperty.__init__ (self, QObject, QString, QDeclarativeContext)

创建QDeclarativeProperty该物业nameobj使用context ctxt

创建QDeclarativeProperty没有上下文会使一些特性 - 像附加属性 - 无法访问。

  1. QDeclarativeProperty.__init__ (self, QObject, QString, QDeclarativeEngine)

创建QDeclarativeProperty该物业nameobj使用环境的实例,是由提供的QML组件engine

  1. QDeclarativeProperty.__init__ (self, QDeclarativeProperty)

创建副本other

  1. bool QDeclarativeProperty.connectNotifySignal (self, QObject dest, SLOT()SLOT() slot)

该属性的改变通知信号连接到指定的slotdest对象并返回True 。返回False,如果该元属性并不代表定期Qt的属性,或者如果它没有改变通知信号,或者如果dest对象不具有指定的slot

  1. bool QDeclarativeProperty.connectNotifySignal (self, callable dest)

该属性的改变通知信号连接到指定的methoddest对象并返回True 。返回False,如果该元属性并不代表定期Qt的属性,或者如果它没有改变通知信号,或者如果dest对象不具有指定的method

  1. bool QDeclarativeProperty.connectNotifySignal (self, QObject dest, int method)
  1. bool QDeclarativeProperty.hasNotifySignal (self)

如果属性有改变通知信号,否则为False ,则返回True 。

  1. int QDeclarativeProperty.index (self)

返回属性的Qt的元对象的索引。

  1. bool QDeclarativeProperty.isDesignable (self)

返回True,如果属性是可设计的,否则为False 。

  1. bool QDeclarativeProperty.isProperty (self)

返回True如果QDeclarativeProperty代表一个普通的Qt属性。

  1. bool QDeclarativeProperty.isResettable (self)

返回True,如果属性是可复位,否则为False 。

  1. bool QDeclarativeProperty.isSignalProperty (self)

返回True如果QDeclarativeProperty代表一个QML信号特性。

  1. bool QDeclarativeProperty.isValid (self)

返回True如果QDeclarativeProperty指的是一个有效的属性,否则为False 。

  1. bool QDeclarativeProperty.isWritable (self)

返回True,如果属性是可写的,否则为False 。

  1. QMetaMethod QDeclarativeProperty.method (self)

返回QMetaMethod这个属性,如果它是一个SignalProperty,否则返回一个无效的QMetaMethod

  1. QString QDeclarativeProperty.name (self)

返回此QML属性的名称。

  1. bool QDeclarativeProperty.needsNotifySignal (self)

如果该属性需要改变通知信号绑定保持upto日期,否则返回False ,则返回True 。

某些属性,如附加属性或那些值永远不会改变,不需要改变通知。

  1. QObject QDeclarativeProperty.object (self)

返回QDeclarativePropertyQObject

  1. QMetaProperty QDeclarativeProperty.property (self)

返回Qt property与此QML属性相关联。

  1. int QDeclarativeProperty.propertyType (self)

返回QVariant类型的财产,或QVariant.Invalid如果该属性没有QVariant类型。

  1. PropertyTypeCategory QDeclarativeProperty.propertyTypeCategory (self)

[

返回属性类别。

  1. str QDeclarativeProperty.propertyTypeName (self)

返回属性的类型名称,或者0,如果属性没有类型名称。

  1. QVariant QDeclarativeProperty.read (self)

返回的属性值。

  1. QVariant QDeclarativeProperty.read (QObject, QString)

返回name物业价值object。此方法等效于:

]($docs-qdeclarativeproperty.html#PropertyTypeCategory-enum)

  1. QDeclarativeProperty p(object, name);
  2. p.read();
  1. QVariant QDeclarativeProperty.read (QObject, QString, QDeclarativeContext)

返回name物业价值object使用context ctxt。此方法等效于:

  1. [QDeclarativeProperty]($docs-qdeclarativeproperty.html) p(object, name, context);
  2. p.read();
  1. QVariant QDeclarativeProperty.read (QObject, QString, QDeclarativeEngine)

返回name物业价值object使用环境的实例,是由提供的QML组件engine。 。此方法等效于:

  1. [QDeclarativeProperty]($docs-qdeclarativeproperty.html) p(object, name, engine);
  2. p.read();
  1. bool QDeclarativeProperty.reset (self)

重置属性,如果属性是可复位返回True 。如果该属性是无法确认,没有任何反应并返回False 。

  1. Type QDeclarativeProperty.type (self)

[

返回属性的类型。

  1. bool QDeclarativeProperty.write (self, QVariant)

属性值设置为value并返回True 。返回False,如果该属性不能被设置,因为value是错误的类型,例如。

  1. bool QDeclarativeProperty.write (QObject, QString, QVariant)

Writes valuename物业object。此方法等效于:

]($docs-qdeclarativeproperty.html#Type-enum)

  1. QDeclarativeProperty p(object, name);
  2. p.write(value);
  1. bool QDeclarativeProperty.write (QObject, QString, QVariant, QDeclarativeContext)

Writes valuename物业object使用context ctxt。此方法等效于:

  1. [QDeclarativeProperty]($docs-qdeclarativeproperty.html) p(object, name, ctxt);
  2. p.write(value);
  1. bool QDeclarativeProperty.write (QObject, QString, QVariant, QDeclarativeEngine)

Writes valuename物业object使用环境的实例,是由提供的QML组件engine。此方法等效于:

  1. [QDeclarativeProperty]($docs-qdeclarativeproperty.html) p(object, name, engine);
  2. p.write(value);
  1. bool QDeclarativeProperty.__eq__ (self, QDeclarativeProperty)
  1. int QDeclarativeProperty.__hash__ (self)
  1. bool QDeclarativeProperty.__ne__ (self, QDeclarativeProperty)