Looking through the Qt source, it seems that when a slot is called from QMetaObject :: invokeMethod, you can specify the return type and get the return value. (Look at invokeMethod in Qt help)
I could not find many examples of how this is really used in the Qt source. I found that
bool QAbstractItemDelegate::helpEvent
which is a return type slot and is called from
QAbstractItemView::viewportEvent
using invokeMethod.
I think that the return value for the slot is only available when the function is called directly (when it is a normal C ++ function) or when using invokeMethod. I think this is really intended for Qt's internal functions, and not for normal use in programs using Qt.
Edit: For example:
case 8: { int _r = selectPart((*reinterpret_cast< AppObject*(*)>(_a[1])), *reinterpret_cast< int(*)>(_a[2]))); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
vector _a is a list of arguments passed to qt_metacall. This is passed to QMetaObject :: invokeMethod. Thus, the return value in the generated moc code is saved and returned back to the caller. Therefore, for normal interactions with the signal-slot, the return value is not used at all. However, a mechanism exists, so that the return values ββfrom the slots can be accessed if the slot is called through invokeMethod.
David Dibben Sep 22 '08 at 3:00 2008-09-22 03:00
source share