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

QMetaProperty QMetaObject::property ( int  index  )  const

Returns the meta-data for the property with the given index. If no such property exists, a null QMetaProperty is returned.

See also:
propertyCount(), propertyOffset(), indexOfProperty()

Definition at line 619 of file qmetaobject.cpp.

References enumerator(), QMetaProperty::handle, QMetaProperty::idx, indexOfEnumerator(), QMetaEnum::isValid(), QByteArray::lastIndexOf(), QByteArray::left(), QMetaProperty::menum, QByteArray::mid(), QMetaProperty::mobj, and propertyOffset().

Referenced by QAbstractFormBuilder::computeProperties(), QObject::property(), QObject::setProperty(), and userProperty().

{
    int i = index;
    i -= propertyOffset();
    if (i < 0 && d.superdata)
        return d.superdata->property(index);

    QMetaProperty result;
    if (i >= 0 && i < priv(d.data)->propertyCount) {
        int handle = priv(d.data)->propertyData + 3*i;
        int flags = d.data[handle + 2];
        const char *type = d.stringdata + d.data[handle + 1];
        result.mobj = this;
        result.handle = handle;
        result.idx = i;

        if (flags & EnumOrFlag) {
            result.menum = enumerator(indexOfEnumerator(type));
            if (!result.menum.isValid()) {
                QByteArray enum_name = type;
                QByteArray scope_name = d.stringdata;
                int s = enum_name.lastIndexOf("::");
                if (s > 0) {
                    scope_name = enum_name.left(s);
                    enum_name = enum_name.mid(s + 2);
                }
                const QMetaObject *scope = 0;
                if (scope_name == "Qt")
                    scope = &QObject::staticQtMetaObject;
                else
                    scope = QMetaObject_findMetaObject(this, scope_name);
                if (scope)
                    result.menum = scope->enumerator(scope->indexOfEnumerator(enum_name));
            }
        }
    }
    return result;
}


Generated by  Doxygen 1.6.0   Back to index