QQmlPropertyclass abstracts accessing properties on objects created from QML. 更多 …
def
__eq__
(arg__1)
def
connectNotifySignal
(dest, method)
def
connectNotifySignal
(dest, slot)
def
hasNotifySignal
()
def
index
()
def
isDesignable
()
def
isProperty
()
def
isResettable
()
def
isSignalProperty
()
def
isValid
()
def
isWritable
()
def
方法
()
def
name
()
def
needsNotifySignal
()
def
object
()
def
特性
()
def
propertyType
()
def
propertyTypeCategory
()
def
propertyTypeName
()
def
read
()
def
reset
()
def
type
()
def
write
(arg__1)
As QML uses Qt’s meta-type system all of the existing
QMetaObjectclasses 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 theQQmlPropertyclass that simplifies some of their natural complexity.不像
QMetaPropertywhich represents a property on a class type,QQmlPropertyencapsulates a property on a specific object instance. To read a property’s value, programmers create aQQmlPropertyinstance and call theread()method. Likewise to write a property value thewrite()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();
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
- param arg__3
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
|
|
QQmlProperty.Object |
The property is a
|
|
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.
propertyType
(
)
¶
int
返回
QVariant
type of the property, or
Invalid
if the property has no
QVariant
类型。
PySide2.QtQml.QQmlProperty.
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.
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();
PySide2.QtQml.QQmlProperty.
read
(
arg__1
,
arg__2
,
arg__3
)
¶
arg__1
–
QObject
arg__2 – unicode
arg__3
–
QQmlEngine
object
PySide2.QtQml.QQmlProperty.
read
(
arg__1
,
arg__2
,
arg__3
)
¶
arg__1
–
QObject
arg__2 – unicode
arg__3
–
QQmlContext
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.
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
否则。
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
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.