views:

98

answers:

2

I am looking for Qt's implemention of the function QObject::qt_metacall(_c, _id, _a); this is where a given function name is converted into index. But I am not able to find the function implementation anywhere in their source code.

int ssObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: readyToPrint(); break;
        case 1: readyToPrint1((*reinterpret_cast< int(*)>(_a[1]))); break;
               //''''

         }
    return _id;
   }

Why is parent class's qt_metacall is called ?

+2  A: 

It calls the method with index _id, of class _c with the arguments in the list _a.

I believe that the implementation is generated by moc, so it is not in any source tree.

e8johan
+2  A: 

You should be able to find moc_qobject.cpp somewhere. It requires you to build Qt as this file is auto-generated, just as your own moc-files.

Here it is from my build (4.6.1 on windows):

int QObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: destroyed((*reinterpret_cast< QObject*(*)>(_a[1]))); break;
        case 1: destroyed(); break;
        case 2: deleteLater(); break;
        case 3: d_func()->_q_reregisterTimers((*reinterpret_cast< void*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 4;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = objectName(); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setObjectName(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 1;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Marcus Lindblom
The piece of code that I have posted is from moc_ssObject.cpp
Passionate programmer
Doh.. Sorry. I've updated my answer and posted the code from my recent Qt build.
Marcus Lindblom