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.1k 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 , I have a break point in the debugger after the connect and can see it contains false.

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

    @SPlatten said in QObject::connect returns false:

    @JonB , I have a break point in the debugger after the connect and can see it contains false.

    Noooo.
    Like I said, print it out........

    SPlattenS 1 Reply Last reply
    0
    • JonBJ JonB

      @SPlatten said in QObject::connect returns false:

      @JonB , I have a break point in the debugger after the connect and can see it contains false.

      Noooo.
      Like I said, print it out........

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

      @JonB, just did that adding:

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

      Shown in console as:

      connect: false
      

      Kind Regards,
      Sy

      JonBJ 2 Replies Last reply
      0
      • SPlattenS SPlatten

        @JonB, just did that adding:

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

        Shown in console as:

        connect: false
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #22

        @SPlatten
        OK, damn!
        Just I warn you now: do not rely on what you see in the debugger for values of variables...!

        1 Reply Last reply
        0
        • SPlattenS SPlatten

          @KroMignon I will look at the generated moc files, but as you can see from my posts the prototypes are identical.

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

          @SPlatten said in QObject::connect returns false:

          I will look at the generated moc files, but as you can see from my posts the prototypes are identical.

          Are you sure header files are in HEADERS in your PRO file?
          Did you (re)run qmake?
          You could also try to remove the build directory to force moc re-run.

          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
          2
          • SPlattenS SPlatten

            @JonB, just did that adding:

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

            Shown in console as:

            connect: false
            
            JonBJ Offline
            JonBJ Offline
            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 Offline
                      JonBJ Offline
                      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 Offline
                              JonBJ Offline
                              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 Offline
                                        JonBJ Offline
                                        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 Offline
                                          JonBJ Offline
                                          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

                                          • Login

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