Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QVariant QObject::property ( const char *  name  )  const [inherited]

Returns the value of the object's name property.

If no such property exists, the returned variant is invalid.

Information about all available properties is provided through the metaObject() and dynamicPropertyNames().

See also:
setProperty(), QVariant::isValid(), metaObject(), dynamicPropertyNames()

Definition at line 3072 of file qobject.cpp.

References QMetaObject::indexOfProperty(), QMetaProperty::isReadable(), QMetaObject::property(), and QMetaProperty::read().

Referenced by QTextDocument::idealWidth(), QDBusAbstractInterface::internalPropGet(), QDBusAbstractInterface::internalPropSet(), Q3SqlPropertyMap::property(), and QItemDelegate::setModelData().

{
    Q_D(const QObject);
    const QMetaObject* meta = metaObject();
    if (!name || !meta)
        return QVariant();

    int id = meta->indexOfProperty(name);
    if (id < 0) {
        if (!d->extraData)
            return QVariant();
        const int i = d->extraData->propertyNames.indexOf(name);
        return d->extraData->propertyValues.value(i);
    }
    QMetaProperty p = meta->property(id);
#ifndef QT_NO_DEBUG
    if (!p.isReadable())
        qWarning("%s::property: Property \"%s\" invalid or does not exist",
                 metaObject()->className(), name);
#endif
    return p.read(this);
}


Generated by  Doxygen 1.6.0   Back to index