Results 1 to 2 of 2

Thread: qRegisterMetaType - problems with connect()

  1. #1
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qRegisterMetaType - problems with connect()

    I created my own class and | wanted to pass it as argument in SIGNALS/SLOTS.
    But when I call emit signal(myClass); I get this error on output:
    Qt Code:
    1. Object::connect: Cannot queue arguments of type 'myClass' (Make sure 'myClass' is registered using qRegisterMetaType()
    To copy to clipboard, switch view to plain text mode 
    I solved the problem by passing pointer to myClass instead of myClass object, but what's wrong in the first method?

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qRegisterMetaType - problems with connect()

    Qt docs fragment:
    . . . Q_DECLARE_METATYPE() doesn't actually register the type; you must still use qRegisterMetaType() for that, particularly if you intend to use the type in signal and slot connections. . .
    You have to register your class to Qt meta objects system. To achieve this you need Q_DECLARE_METATYPE macro and qRegisterMetaType() function. Good explanation you can find in Qt docs (Q_DECLARE_METATYPE and qRegisterMetaType).
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. The following user says thank you to faldzip for this useful post:

    Macok (6th March 2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.