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. QObject::connect returns false
Forum Updated to NodeBB v4.3 + New Features

QObject::connect returns false

Scheduled Pinned Locked Moved Solved General and Desktop
48 Posts 5 Posters 6.8k 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.
  • KroMignonK KroMignon

    @SPlatten said in QObject::connect returns false:

    please see the edited post which includes the derived class, sorry.

    In this header signal signature is void updateTime(int) and not void updateTime(long)

    SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #41

    @KroMignon , because I changed it from long to int after earlier posts.

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • SPlattenS SPlatten

      @J-Hilk , why? The class it inherits already has that.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #42

      @SPlatten said in QObject::connect returns false:

      @J-Hilk , why? The class it inherits already has that.

      That's not how it works. Which is why I said to try putting Q_OBJECT in.

      Can you please do that and then we will discuss why if it makes any difference?

      SPlattenS 1 Reply Last reply
      0
      • JonBJ JonB

        @SPlatten said in QObject::connect returns false:

        @J-Hilk , why? The class it inherits already has that.

        That's not how it works. Which is why I said to try putting Q_OBJECT in.

        Can you please do that and then we will discuss why if it makes any difference?

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #43

        @JonB , adding Q_OBJECT to the inherit class results in the compiler error:

        undefined erference to `vtable for clsTimeSync`
        

        Kind Regards,
        Sy

        jsulmJ SPlattenS 2 Replies Last reply
        0
        • SPlattenS SPlatten

          @JonB , adding Q_OBJECT to the inherit class results in the compiler error:

          undefined erference to `vtable for clsTimeSync`
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #44

          @SPlatten said in QObject::connect returns false:

          results in the compiler error

          You need to do a complete rebuild

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          JonBJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @J-Hilk , why? The class it inherits already has that.

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #45

            @SPlatten said in QObject::connect returns false:

            why? The class it inherits already has that.

            Because it is a Qt recommendation (cf. https://doc.qt.io/qt-5/metaobjects.html)

            The meta-object system is based on three things:

            • The QObject class provides a base class for objects that can take advantage of the meta-object system.
            • The Q_OBJECT macro inside the private section of the class declaration is used to enable meta-object features, such as dynamic properties, signals, and slots.
            • The Meta-Object Compiler (moc) supplies each QObject subclass with the necessary code to implement meta-object features.

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            1 Reply Last reply
            1
            • SPlattenS SPlatten

              @JonB , adding Q_OBJECT to the inherit class results in the compiler error:

              undefined erference to `vtable for clsTimeSync`
              
              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #46

              @KroMignon , @JonB , @J-Hilk , @jsulm , ok, works now I think the missing Q_OBJECT was the issue as having cleaned out the build folder, remake, rebuild, now it works.

              Kind Regards,
              Sy

              1 Reply Last reply
              1
              • jsulmJ jsulm

                @SPlatten said in QObject::connect returns false:

                results in the compiler error

                You need to do a complete rebuild

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #47

                @jsulm said in QObject::connect returns false:

                You need to do a complete rebuild

                As we have said over & over again, it would be nice if people followed that instead of ignoring it.....

                1 Reply Last reply
                1
                • SPlattenS SPlatten

                  @J-Hilk , why? The class it inherits already has that.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #48

                  @SPlatten said in QObject::connect returns false:

                  @J-Hilk , why? The class it inherits already has that.

                  Q_OBJECT is a macro. You can look at what it does.

                  I know the rule is:

                  • Every class which defines signals MUST have Q_OBJECT in that class definition. Inheritance from parent is not what it's about.

                  • Normally I believe slot-only classes do not have to have Q_OBJECT. HOWEVER I only work with the new-style connect() syntax, not available in Qt4. It may be that to use SLOT() you do also need Q_OBJECT in old style? When in doubt --- and certainly if I were having a problem --- I would put Q_OBJECT into classes with slots just in case.....

                  1 Reply Last reply
                  1

                  • Login

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