Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Slot executions problems in a new thread
Qt 6.12 LTS is out! See what's new in the release blog

Slot executions problems in a new thread

Scheduled Pinned Locked Moved General and Desktop
13 Posts 6 Posters 7.3k 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #2

    Do you have a "Q_OBJECT":http://developer.qt.nokia.com/doc/qt-4.8/qobject.html#Q_OBJECT macro also in GestoreComunicazioneEmh class definition?

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #3

      Are you missing the Q_OBJECT macro?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #4

        Now I have:
        @
        class GestoreComunicazioneEmh : public GestoreComunicazioneBase
        {
        Q_OBJECT
        public:
        GestoreComunicazioneEmh()
        ...
        ...
        @

        But with Q_OBJECT the compilation fails:
        @
        Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Debug/../satellite/gestorecomunicazioneemh.cpp:10: undefined reference to `vtable for GestoreComunicazioneEmh'
        @

        I think it's should be a very stupid problem but I can't find it...

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #5

          Re-run qmake. If your class is defined within a <code>.cpp</code> file make sure you <code>#include "filename.moc"</code>.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            luca
            wrote on last edited by
            #6

            Ok, the problem was the missing Q_OBJECT but to solve compilation problem I had to remove all build directory...

            1 Reply Last reply
            0
            • L Offline
              L Offline
              luca
              wrote on last edited by
              #7

              It seems that "Rebuild project" in QtCreator was not enough...

              Thanks all!

              1 Reply Last reply
              0
              • F Offline
                F Offline
                favoritas37
                wrote on last edited by
                #8

                So is it solved? Because it seems that you haven't added the QObject as base class of GestoreComunicazioneEmh:

                @
                class GestoreComunicazioneEmh : public QObject, public GestoreComunicazioneBase
                {
                Q_OBJECT
                public:
                GestoreComunicazioneEmh(QObject* parent=NULL) : QObject(parent) {}
                };
                @

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  luca
                  wrote on last edited by
                  #9

                  Yes I solved by adding Q_OBJECT (a very stupid question :-) ) but when adding it the project building failed also after "Rebuilding it".
                  To solve the problem I also had to remove all files (Makefile too ) in build directory.

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    luca
                    wrote on last edited by
                    #10

                    QObject is in GestoreComunicazioneBase:
                    @
                    class GestoreComunicazioneBase : public QObject
                    {
                    Q_OBJECT
                    public:
                    ...
                    ...
                    @

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #11

                      [quote author="favoritas37" date="1327329544"]So is it solved? Because it seems that you haven't added the QObject as base class of GestoreComunicazioneEmh:

                      @
                      class GestoreComunicazioneEmh : public QObject, public GestoreComunicazioneBase
                      {
                      Q_OBJECT
                      public:
                      GestoreComunicazioneEmh(QObject* parent=NULL) : QObject(parent) {}
                      };
                      @[/quote]

                      This is WRONG! GestoreComunicazioneBase already inherits from QObject, so GestoreComunicazioneEmh is also a QObject subclass, albeit not a direct child class. Adding QObject to the inheritance list makes GestoreComunicazioneEmh in fact inherit from QObject twice, which is a bad, bad, bad idea.

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        favoritas37
                        wrote on last edited by
                        #12

                        Sorry Volker, i mentioned it because i haven't noticed that the base class already inherits from QObject. I wouldn't suggest to inherit twice from QObject.

                        1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #13

                          [quote author="favoritas37" date="1327332502"]Sorry Volker, i mentioned it because i haven't noticed that the base class already inherits from QObject. I wouldn't suggest to inherit twice from QObject. [/quote]

                          No problem, everyone overlooks something now and then :) I just wanted to make sure that another potential trouble maker does sneak in :)

                          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
                          • Unsolved