Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

sending QMap<enum, QString> over Qt DBus



  • I Tried to send QMap<enumType, QString> over Qt DBus but I'm getting below error.

    QDBusMarshaller: type 'test::TEST_ENUM' (1026) cannot be used as the key type in a D-BUS map.
    QDBusMarshaller: type `QMap<test::TEST_ENUM',QString>' produces invalid D-BUS signature `<empty>' (Did you forget to call beginStructure() ?)
    QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type ''
    QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type ''
    

    TEST_ENUM is my enum type defined under test namespace.
    I registered both the enum type and QMap with qDBusRegisterMetaType.

    In header file

    using testMap = QMap<TEST_ENUM, QString>;
    Q_DECLARE_METATYPE(test::TEST_ENUM)
    

    In CPP file

    defined operator<< & operator>> for test::TEST_ENUM
    
    qDBusRegisterMetaType<test::TEST_ENUM>();
    qRegisterMetaType<test::TEST_ENUM>("test::TEST_ENUM");
    qDBusRegisterMetaType<test::testMap>();
    

Log in to reply