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. connect problem!!! QObject::connect: Cannot queue arguments of type "myStruct" (Make sure 'myStruct' is registered using qRegisterMetaType(). )

connect problem!!! QObject::connect: Cannot queue arguments of type "myStruct" (Make sure 'myStruct' is registered using qRegisterMetaType(). )

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 5.7k Views 4 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.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    connect problem!!! QObject::connect: Cannot queue arguments of type "myStruct" (Make sure 'myStruct' is registered using qRegisterMetaType(). )

    O 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      we need the actual code also :)

      1 Reply Last reply
      0
      • JohanSoloJ Offline
        JohanSoloJ Offline
        JohanSolo
        wrote on last edited by
        #3

        The solution is in the error message, use this:

        qRegisterMetaType<myStruct>("myStruct");
        

        Have a look here or there.

        `They did not know it was impossible, so they did it.'
        -- Mark Twain

        1 Reply Last reply
        1
        • O opengpu2

          connect problem!!! QObject::connect: Cannot queue arguments of type "myStruct" (Make sure 'myStruct' is registered using qRegisterMetaType(). )

          O Offline
          O Offline
          opengpu2
          wrote on last edited by opengpu2
          #4

          so even this 'myInt' need register?
          typedef int myInt;
          connect(this, SIGNAL(xxx(myInt), this, SLOT(myInt)));

          1 Reply Last reply
          0
          • JohanSoloJ Offline
            JohanSoloJ Offline
            JohanSolo
            wrote on last edited by
            #5

            To be honest I don't know about typedef'ed basic types. A workaround which I like to use is to send pointers instead of instances (when applicable). You don't need to register the type as long as you're using pointers in your signals / slots.

            `They did not know it was impossible, so they did it.'
            -- Mark Twain

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Yes, even for myInt. myInt is unknown to the Qt MetaObject system.

              @JohanSolo beware when passing pointers especially if it's a multithreaded environment. You have to handle carefully the lifetime of your objects.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              JohanSoloJ 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Yes, even for myInt. myInt is unknown to the Qt MetaObject system.

                @JohanSolo beware when passing pointers especially if it's a multithreaded environment. You have to handle carefully the lifetime of your objects.

                JohanSoloJ Offline
                JohanSoloJ Offline
                JohanSolo
                wrote on last edited by
                #7

                @SGaist said:

                @JohanSolo beware when passing pointers especially if it's a multithreaded environment. You have to handle carefully the lifetime of your objects.

                Yeah, actually I've been bitten recently by this... That's why I said `(when applicable)', I should have put more emphasise on potential problems. Thank you for the warning!

                `They did not know it was impossible, so they did it.'
                -- Mark Twain

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  opengpu2
                  wrote on last edited by
                  #8

                  so if i use 'myInt*' as signal and slot 's param. so i need not register, right?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Just don't do that, it's a base type. Register it and keep your code clean.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    O 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Just don't do that, it's a base type. Register it and keep your code clean.

                      O Offline
                      O Offline
                      opengpu2
                      wrote on last edited by
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        opengpu2
                        wrote on last edited by
                        #11

                        and why Qt need register myInt? it's just simply int: typedef int myInt;

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Again: myInt is an unknown type to the Qt Meta Object system

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          O 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Again: myInt is an unknown type to the Qt Meta Object system

                            O Offline
                            O Offline
                            opengpu2
                            wrote on last edited by
                            #13

                            @SGaist but i found that my code works fine when i use 'myStruct*', and even 'myInt' as signal&slot param.

                            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