Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Signal and slots qRegisterMetaType
Qt 6.11 is out! See what's new in the release blog

Signal and slots qRegisterMetaType

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 12.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suths
    wrote on last edited by
    #1

    Hi guys,

    I'm having a strange problem with some custom typedefs i have defined for smart pointers e.g:
    @
    namspace example
    {
    typedef
    smartPointer;
    }@

    Then a qthead that emits a signal of this type back to a class that runs on the main gui thread:

    @namspace example
    {
    class thread : public QThread
    {
    Q_Object

       public signals:
      void  send(smartPointer);
    

    }
    }@

    Hopefully this short example makes sense.

    I have registered this typedef with the @qRegisterMetaTypeexample::smartPointer(smartPointer);@

    class, and also the QDECLARE_METATYPE(example::smartPointer) macro.

    However in runtime I get a "cannot queue arguments of type example (Make sure 'example' is a registered using qRegisterMetaType().)" error.

    any sugestions would be great

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      [quote author="Suths" date="1352298159"]
      I have registered this typedef with the @qRegisterMetaTypeexample::smartPointer(smartPointer);@
      class[/quote]

      Where exactly do you call that function?

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        You seem to be missing something in your typedef. I'll assume this is something like
        @typedef SomeGiantTypeThatIDontWantToRetypeOrWhatever SmartPointer;@

        qRegisterMetaType takes a string name of your class e.g. @qRegisterMetaTypeexample::SmartPointer("SmartPointer")@

        You can call it wherever just as long as your typedef is visible there and before you use it for connecting or access its metadata.
        Also, make sure you use Q_DECLARE_METATYPE outside of your example namespace.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved