Qt 4.8
|
The QMetaProperty class provides meta-data about a property. More...
#include <qmetaobject.h>
Public Functions | |
const QMetaObject * | enclosingMetaObject () const |
QMetaEnum | enumerator () const |
Returns the enumerator if this property's type is an enumerator type; otherwise the returned value is undefined. More... | |
bool | hasNotifySignal () const |
Returns true if this property has a corresponding change notify signal; otherwise returns false. More... | |
bool | hasStdCppSet () const |
Returns true if the property has a C++ setter function that follows Qt's standard "name" / "setName" pattern. More... | |
bool | isConstant () const |
bool | isDesignable (const QObject *obj=0) const |
Returns true if this property is designable for the given object; otherwise returns false. More... | |
bool | isEditable (const QObject *obj=0) const |
Returns true if the property is constant; otherwise returns false. More... | |
bool | isEnumType () const |
Returns true if the property's type is an enumeration value; otherwise returns false. More... | |
bool | isFinal () const |
bool | isFlagType () const |
Returns true if the property's type is an enumeration value that is used as a flag; otherwise returns false. More... | |
bool | isReadable () const |
Returns true if this property is readable; otherwise returns false. More... | |
bool | isResettable () const |
Returns true if this property can be reset to a default value; otherwise returns false. More... | |
bool | isScriptable (const QObject *obj=0) const |
Returns true if the property is scriptable for the given object; otherwise returns false. More... | |
bool | isStored (const QObject *obj=0) const |
Returns true if the property is stored for object; otherwise returns false. More... | |
bool | isUser (const QObject *obj=0) const |
Returns true if this property is designated as the USER property, i.e., the one that the user can edit for object or that is significant in some other way. More... | |
bool | isValid () const |
Returns true if this property is valid (readable); otherwise returns false. More... | |
bool | isWritable () const |
Returns true if this property is writable; otherwise returns false. More... | |
const char * | name () const |
Returns this property's name. More... | |
QMetaMethod | notifySignal () const |
Returns the QMetaMethod instance of the property change notifying signal if one was specified, otherwise returns an invalid QMetaMethod. More... | |
int | notifySignalIndex () const |
Returns the index of the property change notifying signal if one was specified, otherwise returns -1. More... | |
int | propertyIndex () const |
Returns this property's index. More... | |
QMetaProperty () | |
QVariant | read (const QObject *obj) const |
Reads the property's value from the given object. More... | |
bool | reset (QObject *obj) const |
Resets the property for the given object with a reset method. More... | |
int | revision () const |
Returns the property revision if one was specified by REVISION, otherwise returns 0. More... | |
QVariant::Type | type () const |
Returns this property's type. More... | |
const char * | typeName () const |
Returns the name of this property's type. More... | |
int | userType () const |
Returns this property's user type. More... | |
bool | write (QObject *obj, const QVariant &value) const |
Writes value as the property's value to the given object. More... | |
Properties | |
uint | handle |
int | idx |
QMetaEnum | menum |
const QMetaObject * | mobj |
Friends | |
struct | QMetaObject |
The QMetaProperty class provides meta-data about a property.
Property meta-data is obtained from an object's meta-object. See QMetaObject::property() and QMetaObject::propertyCount() for details.
A property has a name() and a type(), as well as various attributes that specify its behavior: isReadable(), isWritable(), isDesignable(), isScriptable(), and isStored().
If the property is an enumeration, isEnumType() returns true; if the property is an enumeration that is also a flag (i.e. its values can be combined using the OR operator), isEnumType() and isFlagType() both return true. The enumerator for these types is available from enumerator().
The property's values are set and retrieved with read(), write(), and reset(); they can also be changed through QObject's set and get functions. See QObject::setProperty() and QObject::property() for details.
QMetaProperty objects can be copied by value. However, each copy will refer to the same underlying property meta-data.
Definition at line 176 of file qmetaobject.h.
QMetaProperty::QMetaProperty | ( | ) |
Definition at line 2134 of file qmetaobject.cpp.
|
inline |
Definition at line 214 of file qmetaobject.h.
QMetaEnum QMetaProperty::enumerator | ( | ) | const |
Returns the enumerator if this property's type is an enumerator type; otherwise the returned value is undefined.
Definition at line 2294 of file qmetaobject.cpp.
Referenced by QDeclarativeCompiler::genLiteralAssignment(), QDeclarativeCompiler::testLiteralAssignment(), QDeclarativeCompiler::testQualifiedEnumAssignment(), and QDeclarativePropertyPrivate::writeEnumProperty().
bool QMetaProperty::hasNotifySignal | ( | ) | const |
Returns true if this property has a corresponding change notify signal; otherwise returns false.
Definition at line 2481 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativeVMEMetaObject::connectAlias(), QDeclarativeProperty::connectNotifySignal(), ShaderEffectItem::connectPropertySignals(), QDeclarativeBindingCompilerPrivate::fetch(), QDeclarativePropertyPrivate::findSignalByName(), QDeclarativeProperty::hasNotifySignal(), notifySignalIndex(), QDeclarativeEngineDebugService::propertyData(), and QDeclarativeWatchProxy::QDeclarativeWatchProxy().
bool QMetaProperty::hasStdCppSet | ( | ) | const |
Returns true if the property has a C++ setter function that follows Qt's standard "name" / "setName" pattern.
Designer and uic query hasStdCppSet() in order to avoid expensive QObject::setProperty() calls. All properties in Qt [should] follow this pattern.
Definition at line 2279 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty().
bool QMetaProperty::isConstant | ( | ) | const |
bool QMetaProperty::isDesignable | ( | const QObject * | object = 0 | ) | const |
Returns true if this property is designable for the given object; otherwise returns false.
If no object is given, the function returns false if the )
's ;.
Definition at line 2587 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativeProperty::isDesignable(), and QStyleSheetStyle::setProperties().
bool QMetaProperty::isEditable | ( | const QObject * | object = 0 | ) | const |
Returns true if the property is constant; otherwise returns false.
A property is constant if the <tt>)</tt>'s \c; const
{ if (!mobj) return false; int flags = mobj->d.data[handle + 2]; return flags & Constant; }
/*!
Returns true if the property is final; otherwise returns false. \since 4.6 A property is final if the <tt>)</tt>'s \c; const
{ if (!mobj) return false; int flags = mobj->d.data[handle + 2]; return flags & Final; }
/*!
Returns true if the property is editable for the given \a object; otherwise returns false.
If no \a object is given, the function returns false if the <tt>)</tt>'s \c;. \sa isDesignable(), isScriptable(), isStored()
Definition at line 2717 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty().
bool QMetaProperty::isEnumType | ( | ) | const |
Returns true if the property's type is an enumeration value; otherwise returns false.
Definition at line 2258 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativeCompiler::compileAlias(), QScript::QtPropertyFunction::execute(), QDeclarativePropertyCache::Data::flagsForProperty(), QDeclarativeCompiler::genLiteralAssignment(), QAxBase::internalProperty(), isFlagType(), qax_generateDocumentation(), read(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeCompiler::testLiteralAssignment(), QDeclarativeCompiler::testQualifiedEnumAssignment(), type(), userType(), write(), and QDeclarativePropertyPrivate::writeEnumProperty().
bool QMetaProperty::isFinal | ( | ) | const |
bool QMetaProperty::isFlagType | ( | ) | const |
Returns true if the property's type is an enumeration value that is used as a flag; otherwise returns false.
Flags can be combined using the OR operator. A flag type is implicitly also an enum type.
Definition at line 2247 of file qmetaobject.cpp.
Referenced by QDeclarativeCompiler::genLiteralAssignment(), QDeclarativeCompiler::testLiteralAssignment(), QDeclarativeCompiler::testQualifiedEnumAssignment(), write(), and QDeclarativePropertyPrivate::writeEnumProperty().
bool QMetaProperty::isReadable | ( | ) | const |
Returns true if this property is readable; otherwise returns false.
Definition at line 2467 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), generateInterfaceXml(), QAxServerBase::Invoke(), QObject::property(), qax_generateDocumentation(), and readAllProperties().
bool QMetaProperty::isResettable | ( | ) | const |
Returns true if this property can be reset to a default value; otherwise returns false.
Definition at line 2454 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativePropertyCache::Data::flagsForProperty(), and reset().
bool QMetaProperty::isScriptable | ( | const QObject * | object = 0 | ) | const |
Returns true if the property is scriptable for the given object; otherwise returns false.
If no object is given, the function returns false if the )
's ;.
Definition at line 2612 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativePropertyCache::append(), QDeclarativeEngineDebugService::buildObjectDump(), QDeclarativeCompiler::buildProperty(), QDeclarativeCompiler::buildValueTypeProperty(), QDeclarativeCompiler::compileAlias(), QDeclarativePropertyCache::create(), QScript::QObjectDelegate::deleteProperty(), QDeclarativeCompiler::doesPropertyExist(), QScript::QtPropertyFunction::execute(), generateInterfaceXml(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QScript::isEnumerableMetaProperty(), QScript::QObjectDelegate::put(), qDBusPropertyGet(), readAllProperties(), and writeProperty().
bool QMetaProperty::isStored | ( | const QObject * | object = 0 | ) | const |
Returns true if the property is stored for object; otherwise returns false.
If no object is given, the function returns false if the )
's ;.
Definition at line 2635 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty().
bool QMetaProperty::isUser | ( | const QObject * | object = 0 | ) | const |
Returns true if this property is designated as the USER
property, i.e., the one that the user can edit for object or that is significant in some other way.
Otherwise it returns false. e.g., the text
property is the USER
editable property of a QLineEdit.
If object is null, the function returns false if the {
)}'s ;, isDesignable(), isScriptable()
Definition at line 2659 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), and QMetaObject::userProperty().
|
inline |
Returns true if this property is valid (readable); otherwise returns false.
Definition at line 213 of file qmetaobject.h.
Referenced by QScript::QtPropertyFunction::execute(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QAxBase::internalProperty(), and QScript::isEnumerableMetaProperty().
bool QMetaProperty::isWritable | ( | ) | const |
Returns true if this property is writable; otherwise returns false.
Definition at line 2569 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativeCompiler::buildGroupedProperty(), QDeclarativeCompiler::buildPropertyObjectAssignment(), QDeclarativeCompiler::buildPropertyOnAssignment(), QDeclarativeCompiler::compileAlias(), QScript::flagsForMetaProperty(), QDeclarativePropertyCache::Data::flagsForProperty(), generateInterfaceXml(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QAxServerBase::Invoke(), qax_generateDocumentation(), QDeclarativeValueTypeScriptClass::queryProperty(), QStyleSheetStyle::setProperties(), QObject::setProperty(), QDeclarativeCompiler::testLiteralAssignment(), QDeclarativeCompiler::testQualifiedEnumAssignment(), QPropertyAnimationPrivate::updateMetaProperty(), write(), and QDeclarativePropertyPrivate::writeEnumProperty().
const char * QMetaProperty::name | ( | ) | const |
Returns this property's name.
Definition at line 2145 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativePropertyCache::append(), QDeclarativeCompiler::buildObject(), QDeclarativeCompiler::buildProperty(), QDeclarativeCompiler::doesPropertyExist(), QDeclarativeVisualDataModelPrivate::ensureRoles(), generateInterfaceXml(), QScript::QObjectDelegate::getOwnPropertyNames(), QAxBase::internalProperty(), QAxServerBase::Invoke(), QScript::isEnumerableMetaProperty(), QAxServerBase::Load(), QDataWidgetMapper::mappedPropertyName(), QDeclarativeProperty::name(), QDeclarativePropertyCache::Data::name(), QDBusAbstractInterfacePrivate::property(), QDeclarativeEngineDebugService::propertyChanged(), QDeclarativeEngineDebugService::propertyData(), QDeclarativeObjectScriptClass::propertyNames(), qax_generateDocumentation(), qax_noSuchFunction(), read(), readAllProperties(), QDeclarativeCompiledBindingsPrivate::run(), QAxServerBase::Save(), QStyledItemDelegate::setEditorData(), QItemDelegate::setEditorData(), QStyledItemDelegate::setModelData(), QItemDelegate::setModelData(), QDeclarativeCompiler::testLiteralAssignment(), QDeclarativeCompiler::testQualifiedEnumAssignment(), and QDeclarativeQtScriptExpression::updateGuards().
QMetaMethod QMetaProperty::notifySignal | ( | ) | const |
Returns the QMetaMethod instance of the property change notifying signal if one was specified, otherwise returns an invalid QMetaMethod.
Definition at line 2500 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativeProperty::connectNotifySignal(), ShaderEffectItem::connectPropertySignals(), and QDeclarativePropertyPrivate::findSignalByName().
int QMetaProperty::notifySignalIndex | ( | ) | const |
Returns the index of the property change notifying signal if one was specified, otherwise returns -1.
Definition at line 2520 of file qmetaobject.cpp.
Referenced by QDeclarativeVMEMetaObject::connectAlias(), QDeclarativeProperty::connectNotifySignal(), QDeclarativeBindingCompilerPrivate::fetch(), QDeclarativePropertyCache::Data::load(), notifySignal(), and QDeclarativeWatchProxy::QDeclarativeWatchProxy().
int QMetaProperty::propertyIndex | ( | ) | const |
Returns this property's index.
Definition at line 2230 of file qmetaobject.cpp.
Referenced by QDeclarativeCompiler::buildProperty(), QDeclarativeCompiler::genLiteralAssignment(), and QDeclarativePropertyCache::Data::load().
Reads the property's value from the given object.
Returns the value if it was able to read it; otherwise returns an invalid variant.
Definition at line 2305 of file qmetaobject.cpp.
Referenced by QDeclarativeContext::contextProperty(), QScript::QtPropertyFunction::execute(), QDeclarativeCompiledBindingsPrivate::findproperty(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QDeclarativeVisualDataModelDataMetaObject::initialValue(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeWatchProxy::notifyValueChanged(), QDeclarativeValueTypeScriptClass::property(), QDeclarativeObjectScriptClass::property(), QObject::property(), QDeclarativeEngineDebugService::propertyData(), qDBusPropertyGet(), readAllProperties(), and QDeclarativePropertyPrivate::readValueProperty().
bool QMetaProperty::reset | ( | QObject * | object | ) | const |
Resets the property for the given object with a reset method.
Returns true if the reset worked; otherwise returns false.
Reset methods are optional; only a few properties support them.
Definition at line 2439 of file qmetaobject.cpp.
int QMetaProperty::revision | ( | ) | const |
Returns the property revision if one was specified by REVISION, otherwise returns 0.
Definition at line 2540 of file qmetaobject.cpp.
Referenced by QDeclarativeBindingCompilerPrivate::fetch(), QDeclarativeTypePrivate::init(), and QDeclarativePropertyCache::Data::load().
QVariant::Type QMetaProperty::type | ( | ) | const |
Returns this property's type.
The return value is one of the values of the QVariant::Type enumeration.
Definition at line 2172 of file qmetaobject.cpp.
Referenced by QDeclarativeCompiler::compileAlias(), QAxBase::internalProperty(), QAxEventSink::OnChanged(), QDBusAbstractInterfacePrivate::property(), QDeclarativeCompiler::testLiteralAssignment(), userType(), and writeProperty().
const char * QMetaProperty::typeName | ( | ) | const |
Returns the name of this property's type.
Definition at line 2158 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addProperty(), QDeclarativeCompiler::compileAlias(), QAxBase::dynamicCallHelper(), QAxEventSink::findProperty(), generateInterfaceXml(), QAxBase::internalProperty(), QAxServerBase::Invoke(), QDBusAbstractInterfacePrivate::property(), QDeclarativeEngineDebugService::propertyData(), QDeclarativeProperty::propertyTypeName(), qax_generateDocumentation(), read(), readAllProperties(), QAxServerBase::Save(), type(), userType(), write(), and writeProperty().
int QMetaProperty::userType | ( | ) | const |
Returns this property's user type.
The return value is one of the values that are registered with QMetaType, or 0 if the type is not registered.
Definition at line 2210 of file qmetaobject.cpp.
Referenced by QDeclarativeCompiler::buildProperty(), QDeclarativeCompiler::buildValueTypeProperty(), QScript::QtPropertyFunction::execute(), QDeclarativeBindingCompilerPrivate::fetch(), QDeclarativePropertyCache::Data::flagsForProperty(), QDeclarativeCompiler::genLiteralAssignment(), QDeclarativePropertyPrivate::initProperty(), QDeclarativePropertyCache::Data::load(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeWatchProxy::notifyValueChanged(), QDeclarativeEngineDebugService::propertyData(), QDeclarativePropertyPrivate::saveValueType(), QDeclarativeValueTypeScriptClass::setProperty(), and QDeclarativeCompiler::testLiteralAssignment().
Writes value as the property's value to the given object.
Returns true if the write succeeded; otherwise returns false.
Definition at line 2369 of file qmetaobject.cpp.
Referenced by QScript::QtPropertyFunction::execute(), QDeclarativeValueTypeScriptClass::setProperty(), QObject::setProperty(), and writeProperty().
|
friend |
Definition at line 221 of file qmetaobject.h.
|
private |
Definition at line 218 of file qmetaobject.h.
Referenced by hasNotifySignal(), hasStdCppSet(), isDesignable(), isEnumType(), isReadable(), isResettable(), isScriptable(), isStored(), isUser(), isWritable(), name(), QMetaObject::property(), read(), revision(), type(), typeName(), and write().
|
private |
Definition at line 219 of file qmetaobject.h.
Referenced by hasStdCppSet(), isDesignable(), isEnumType(), isScriptable(), isStored(), isUser(), name(), notifySignalIndex(), QMetaObject::property(), propertyIndex(), read(), reset(), revision(), type(), typeName(), and write().
|
private |
Definition at line 220 of file qmetaobject.h.
Referenced by enumerator(), isEnumType(), isFlagType(), QMetaObject::property(), read(), type(), userType(), and write().
|
private |
Definition at line 217 of file qmetaobject.h.
Referenced by hasNotifySignal(), hasStdCppSet(), isDesignable(), isEnumType(), isReadable(), isResettable(), isScriptable(), isStored(), isUser(), isWritable(), name(), notifySignal(), notifySignalIndex(), QMetaObject::property(), propertyIndex(), read(), reset(), revision(), type(), typeName(), and write().