QDBusPendingReply: type(custom) not registered with QtDBus issue even when registered custom type it.



  • Hi,

    I am using an custom type which is Qlist of a structure. I am performing all the steps which are mentioned to register it but while executing i am getting runtime error "QDBusPendingReply: type Mylist not registered with QtDBus".
    Please find snippet of my code:-

    struct MyStruct
    {
    	quint8 a;
    	quint32 b;
    	double c;
    	quint32 d;
    };
    

    typedef QList<MyStruct> MyList;

    Q_DECLARE_METATYPE(MyStruct)
    Q_DECLARE_METATYPE(MyList)

    QDBusArgument &operator<<(QDBusArgument &, const MyStruct&);
    const QDBusArgument &operator>>(const QDBusArgument &, MyStruct&);

    QDBusArgument &operator<<(QDBusArgument &argument, const MyStruct &myStruct)
    {
    argument.beginStructure();
    argument << myStruct.a<< myStruct.b<< myStruct.c<< myStruct.d;
    argument.endStructure();
    return argument;
    }

    const QDBusArgument &operator>>(const QDBusArgument &argument, MyStruct &myStruct)
    {
    argument.beginStructure();
    argument >> myStruct.a>> myStruct.b>> myStruct.c>> myStruct.d;
    argument.endStructure();
    return argument;
    }

    void registerMetaTypes()
    {
    qDBusRegisterMetaType<MyStruct>();
    qDBusRegisterMetaType<MyList>();

    qRegisterMetaType<MyStruct>("MyStruct");
    qRegisterMetaType<MyList>("MyList");
    }

    I am facing error at below mentioned line in my code:-
    QDBusPendingReply<int, QList<MyStruct> > reply(*watch);

    Please suggest if any other change is required to be done.


  • Lifetime Qt Champion

    Hi,

    I haven't used that module yet but one thing you should do is remove the string argument from your qRegisterMetaType calls. This version of the function is to register alias types.

    Hope it helps



  • Even after removing that same issue exists.


  • Lifetime Qt Champion

    When are you calling these functions ?



  • Hi,

    It was not getting called from anywhere. After calling registerMetaTypes() issue got resolved. Thanks for pointing it out.

    Thanks for you help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.