Search code examples
qtqt4

How do I receive QList<QVariantMap> over dbus in qt 4.8?


I have C++ code that communicates with another process which returns a list of string->variant mappings, in other words a QList<QVariantMap>. In QT5 I can demarshall QDbusArgument reply as follows:

    QList<QVariantMap> replyMap = qdbus_cast<QList<QVariantMap>>(reply.arguments().first());

This doesn't work with QT4.8. I suspect I need the correct invocation of qDbusRegisterMetaType, but try as I might, I cannot figure out the magic combination. The compiler responds:

..../include/QtCore/qmetatype.h:169:79: error: ‘qt_metatype_id’ is not a member of ‘QMetaTypeId<QList<QMap<QString, QVariant> > >’

Unfortunately our code base is stuck on QT4.8 for now, so an upgrade to QT5 is not possible.

How do I do the same thing in qt4?


Solution

  • A colleague helped me out. The answer is to put this in a header file somewhere.

    Q_DECLARE_METATYPE (QList<QVariantMap>);