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 7.2k 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.
  • SPlattenS SPlatten

    @JonB, just did that adding:

    qDebug() << "connect: " << blnRC;
    

    Shown in console as:

    connect: false
    
    JonBJ Online
    JonBJ Online
    JonB
    wrote on last edited by
    #24

    @SPlatten
    Like I said, have you done a delete and fresh rebuild?
    Does clsTimeEmu have Q_OBJECT in it?

    1 Reply Last reply
    0
    • SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by
      #25

      @J-Hilk , @JonB , @KroMignon , I've looked at both moc files, moc_clsTimeEmu.cpp has the signal:

      // SIGNAL_0
      void clsTimeEmu::epoch(int _t1)
      {
          void *_a[] = { 0, const_cast<void*>reinterpret_cast<const void*>(&_t)) };
          QMetaObject::activate(this, &staticMetaObject, 0, _a);
      }
      

      moc_clsSchdSrv.cpp does not have anything that looks like the slot, no mention of updateTime at all, why ?

      Kind Regards,
      Sy

      J.HilkJ KroMignonK JonBJ 3 Replies Last reply
      0
      • SPlattenS SPlatten

        @J-Hilk , @JonB , @KroMignon , I've looked at both moc files, moc_clsTimeEmu.cpp has the signal:

        // SIGNAL_0
        void clsTimeEmu::epoch(int _t1)
        {
            void *_a[] = { 0, const_cast<void*>reinterpret_cast<const void*>(&_t)) };
            QMetaObject::activate(this, &staticMetaObject, 0, _a);
        }
        

        moc_clsSchdSrv.cpp does not have anything that looks like the slot, no mention of updateTime at all, why ?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #26

        @SPlatten well, can you post more of the clsSchdSrv header ?


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        SPlattenS 1 Reply Last reply
        0
        • SPlattenS SPlatten

          @J-Hilk , @JonB , @KroMignon , I've looked at both moc files, moc_clsTimeEmu.cpp has the signal:

          // SIGNAL_0
          void clsTimeEmu::epoch(int _t1)
          {
              void *_a[] = { 0, const_cast<void*>reinterpret_cast<const void*>(&_t)) };
              QMetaObject::activate(this, &staticMetaObject, 0, _a);
          }
          

          moc_clsSchdSrv.cpp does not have anything that looks like the slot, no mention of updateTime at all, why ?

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

          @SPlatten said in QObject::connect returns false:

          moc_clsSchdSrv.cpp does not have anything that looks like the slot, no mention of updateTime at all, why ?

          Some time Qt-Creator do not detect changes is HEADERS files, so moc will not be re-run.
          This is why I suggest you to try to re-run yourself qmake and, if this not help, remove the build directory (as also suggested by @JonB ) to force full rebuild (with moc).

          But first, make sure all headers are present in HEADERS of your PRO file.

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

          SPlattenS 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @SPlatten well, can you post more of the clsSchdSrv header ?

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

            @J-Hilk , clsSchdSrv.h, still a early work in progress:

            class clsSchdSrv : public QTimer {
                Q_OBJECT
            
            public:
                explicit clsSchdSrv(QObject* pParent = 0);
                void kick();
            
            public slots:
                virtual void expired() = 0;
            }
            

            Sorry, should have added:

            class clsTimeSync : public clsSchdSrv {
            public:
                explicit clsTimeSync();
            
            public slots:
                virtual void expired();
                void updateTime(int intTimeNow);
            }
            

            Kind Regards,
            Sy

            jsulmJ J.HilkJ JonBJ KroMignonK 4 Replies Last reply
            0
            • SPlattenS SPlatten

              @J-Hilk , @JonB , @KroMignon , I've looked at both moc files, moc_clsTimeEmu.cpp has the signal:

              // SIGNAL_0
              void clsTimeEmu::epoch(int _t1)
              {
                  void *_a[] = { 0, const_cast<void*>reinterpret_cast<const void*>(&_t)) };
                  QMetaObject::activate(this, &staticMetaObject, 0, _a);
              }
              

              moc_clsSchdSrv.cpp does not have anything that looks like the slot, no mention of updateTime at all, why ?

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #29

              @SPlatten
              We have all said several times to try a complete delete and re-build.....

              1 Reply Last reply
              0
              • SPlattenS SPlatten

                @J-Hilk , clsSchdSrv.h, still a early work in progress:

                class clsSchdSrv : public QTimer {
                    Q_OBJECT
                
                public:
                    explicit clsSchdSrv(QObject* pParent = 0);
                    void kick();
                
                public slots:
                    virtual void expired() = 0;
                }
                

                Sorry, should have added:

                class clsTimeSync : public clsSchdSrv {
                public:
                    explicit clsTimeSync();
                
                public slots:
                    virtual void expired();
                    void updateTime(int intTimeNow);
                }
                
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #30

                @SPlatten You should see a warning at runtime when connect is executed: what does it say?

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

                1 Reply Last reply
                0
                • KroMignonK KroMignon

                  @SPlatten said in QObject::connect returns false:

                  moc_clsSchdSrv.cpp does not have anything that looks like the slot, no mention of updateTime at all, why ?

                  Some time Qt-Creator do not detect changes is HEADERS files, so moc will not be re-run.
                  This is why I suggest you to try to re-run yourself qmake and, if this not help, remove the build directory (as also suggested by @JonB ) to force full rebuild (with moc).

                  But first, make sure all headers are present in HEADERS of your PRO file.

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

                  @KroMignon, I deleted the content of the build folder , checking for any hidden files, then ran clean, remake and build, same results.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0
                  • SPlattenS SPlatten

                    @J-Hilk , clsSchdSrv.h, still a early work in progress:

                    class clsSchdSrv : public QTimer {
                        Q_OBJECT
                    
                    public:
                        explicit clsSchdSrv(QObject* pParent = 0);
                        void kick();
                    
                    public slots:
                        virtual void expired() = 0;
                    }
                    

                    Sorry, should have added:

                    class clsTimeSync : public clsSchdSrv {
                    public:
                        explicit clsTimeSync();
                    
                    public slots:
                        virtual void expired();
                        void updateTime(int intTimeNow);
                    }
                    
                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #32

                    @SPlatten if thats the header, than I as well fail to see the slot void updateTime(long); declaration ;)


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    0
                    • SPlattenS SPlatten

                      @J-Hilk , clsSchdSrv.h, still a early work in progress:

                      class clsSchdSrv : public QTimer {
                          Q_OBJECT
                      
                      public:
                          explicit clsSchdSrv(QObject* pParent = 0);
                          void kick();
                      
                      public slots:
                          virtual void expired() = 0;
                      }
                      

                      Sorry, should have added:

                      class clsTimeSync : public clsSchdSrv {
                      public:
                          explicit clsTimeSync();
                      
                      public slots:
                          virtual void expired();
                          void updateTime(int intTimeNow);
                      }
                      
                      JonBJ Online
                      JonBJ Online
                      JonB
                      wrote on last edited by JonB
                      #33

                      @SPlatten said in QObject::connect returns false:

                      public slots:
                      virtual void expired() = 0;

                      But you use SLOT(updateTime())?

                      Why are you showing us clsSchdSrv? Earlier you showed clsTimeSync?

                      SPlattenS 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @J-Hilk , clsSchdSrv.h, still a early work in progress:

                        class clsSchdSrv : public QTimer {
                            Q_OBJECT
                        
                        public:
                            explicit clsSchdSrv(QObject* pParent = 0);
                            void kick();
                        
                        public slots:
                            virtual void expired() = 0;
                        }
                        

                        Sorry, should have added:

                        class clsTimeSync : public clsSchdSrv {
                        public:
                            explicit clsTimeSync();
                        
                        public slots:
                            virtual void expired();
                            void updateTime(int intTimeNow);
                        }
                        
                        KroMignonK Offline
                        KroMignonK Offline
                        KroMignon
                        wrote on last edited by
                        #34

                        @SPlatten said in QObject::connect returns false:

                        clsSchdSrv.h, still a early work in progress:

                        I am not sure, you can declare a slot as virtual.
                        I would change this to:

                        class clsSchdSrv : public QTimer {
                            Q_OBJECT
                        
                        public:
                            explicit clsSchdSrv(QObject* pParent = 0);
                            void kick();
                        
                        public:
                             virtual void  onExpired() = 0;
                        public slots:
                            void expired() {  onExpired(); } 
                        }
                        

                        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
                        0
                        • JonBJ JonB

                          @SPlatten said in QObject::connect returns false:

                          public slots:
                          virtual void expired() = 0;

                          But you use SLOT(updateTime())?

                          Why are you showing us clsSchdSrv? Earlier you showed clsTimeSync?

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

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

                          Kind Regards,
                          Sy

                          J.HilkJ KroMignonK JonBJ 3 Replies Last reply
                          0
                          • SPlattenS SPlatten

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

                            J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by J.Hilk
                            #36

                            @SPlatten your derived class will need the Q_OBJECT macro as well, if it defines slots/signals


                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            SPlattenS 1 Reply Last reply
                            1
                            • SPlattenS SPlatten

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

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

                              @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)

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

                              JonBJ SPlattenS 2 Replies Last reply
                              0
                              • SPlattenS SPlatten

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

                                JonBJ Online
                                JonBJ Online
                                JonB
                                wrote on last edited by
                                #38

                                @SPlatten
                                class clsTimeSync : public clsSchdSrv {
                                Although updateTime() is only a slot and not a signal, you do not have Q_OBJECT in this class. Does it help if you do (and then rebuild from scratch)?

                                1 Reply Last reply
                                0
                                • 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)

                                  JonBJ Online
                                  JonBJ Online
                                  JonB
                                  wrote on last edited by
                                  #39

                                  @KroMignon said in QObject::connect returns false:

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

                                  That's coz he has changed per earlier on.
                                  I agree we do not know for sure what his code is, but I think he dealt with that alteration.

                                  1 Reply Last reply
                                  0
                                  • J.HilkJ J.Hilk

                                    @SPlatten your derived class will need the Q_OBJECT macro as well, if it defines slots/signals

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

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

                                    Kind Regards,
                                    Sy

                                    JonBJ KroMignonK 3 Replies Last reply
                                    0
                                    • 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 Online
                                        JonBJ Online
                                        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

                                          • Login

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