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. Problem with signals and slots...
QtWS25 Last Chance

Problem with signals and slots...

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 5 Posters 1.0k Views
  • 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 Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    Since the update to Qt Creator 4.14.0 and 5.15.2, I am getting:

    clsMsgSender::tryToConnect is not a signal [clazy-connect-non-signal]
    

    This is now typical on every connect I have, the above is on the line:

    QObject::connect(this, &clsMsgSender::tryToConnect
                    ,this, &clsMsgSender::onTryToConnect);
    

    This connect is in the class clsMsgSender, the prototype for this class:

        class clsMsgSender : public QObject {
        Q_OBJECT
    
        private:        
            static const quint16 mscuint16ConnectionTO;
            static mpMsgSenders msmpMsgSenders;
            static clsMsgSender* mspService;
            static QThread* mspThread;
            static qulonglong msulnglngMsgID;
    
            bool mblnRun;
            QTcpSocket* mpsckClient;
            mqueJSON mqueMsgsOut;
            QMutex mMutex;
            quint16 muint16Port;
    
            bool blnAnythingToDo(QJsonObject& robjJSON);
            void push(QJsonObject& robjJSON);
    
        public:
            explicit clsMsgSender(quint16 uint16Port);
            ~clsMsgSender();
    
            QTcpSocket* pGetClient() { return mpsckClient; }
            static clsMsgSender* pGetMsgSndr(quint16 uint16Port);
            static clsMsgSender* pGetService() { return clsMsgSender::mspService; }
            static QString strGetLocalIP();
            void terminate() { mblnRun = false; }
            quint16 uint16Port() { return muint16Port; }
            static qulonglong ulnglngGetMsgID() { return clsMsgSender::msulnglngMsgID; }
    
        signals:
            void cannotConnect();
            void connected();
            void disconnected();
            void finished();
            void sendJSON(QJsonObject robjJSON);
            void startService();
            void tryToConnect(const QString& crstrHost, const quint16 cint16Port);
            void write(QJsonObject robjJSON);
    
        public slots:        
            void onCreateMsgSndrThrd();
            void onErrorOccurred(QAbstractSocket::SocketError sckError);
            void onSendJSON(QJsonObject robjJSON);
            void onStartMsgSndrThrd();
            void onTryToConnect(const QString& crstrHost, const quint16 cint16Port);
            void onWrite(QJsonObject robjJSON);
            void run();
        };
    

    Using the debugger I have stepped over an emit of the tryToConnect:

    emit tryToConnect(clsMsgSender::strGetLocalIP(), muint16Port);
    

    With a breakpoint in the onTryToConnect slot:

    void clsMsgSender::onTryToConnect(const QString& crstrHost, const quint16 cint16Port) {
        //Get local IP address
        qdbg() << "Connecting to: " << crstrHost << ":" << cint16Port;
        //Connect to the Application
        mpsckClient->connectToHost(crstrHost, cint16Port);
    
        if ( mpsckClient->waitForConnected(clsMsgSender::mscuint16ConnectionTO) != true ) {
            emit cannotConnect();
        }
    }
    

    The breakpoint is on the qdbg() line, it never gets there. I am assuming that this is related to the warning message, but why? This looks like a Qt Creator issue, how can I fix this? In desperation I uninstalled Qt Creator and the Qt folder then re-installed again, it automatically installs Qt Creator 4.14.0 and 5.15.2.

    Anyone else using these versions and found the same problems?

    1 Reply Last reply
    0
    • SPlattenS SPlatten

      @JonB , how?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #10

      @SPlatten
      hi

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

        Hi,

        @SPlatten said in Problem with signals and slots...:

        Using the debugger I have stepped over an emit of the tryToConnect:
        emit mpobjMsgSender->sendJSON(objMsg);

        With a breakpoint in the onTryToConnect slot:

        How is sendJSON related to onTryToConnect ?

        By the way, signals should only be emitted from within the classes they are defined in.

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

        SPlattenS 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          @SPlatten said in Problem with signals and slots...:

          Using the debugger I have stepped over an emit of the tryToConnect:
          emit mpobjMsgSender->sendJSON(objMsg);

          With a breakpoint in the onTryToConnect slot:

          How is sendJSON related to onTryToConnect ?

          By the way, signals should only be emitted from within the classes they are defined in.

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

          @SGaist , sorry, my bad, I cut and pasted the wrong code into the post, will correct now. The emit I pasted in is called from the run() which is a slot within the same class.

          void clsMsgSender::run() {    
              QTcpSocket::SocketState sckCurState, sckLastState;
              QJsonObject objJSON;
              while( mblnRun == true  ) {
              //Sleep to allow a small cap between transmission
                  QThread::usleep(100);
          
                  sckCurState = mpsckClient->state();
          
                  if ( sckLastState != sckCurState ) {
                      sckLastState = sckCurState;
                      qdbg() << mpsckClient->state();
                  }
                  if ( mpsckClient->state() != QAbstractSocket::ConnectedState ) {
                      if ( mpsckClient->state() != QAbstractSocket::ConnectingState ) {
                          emit tryToConnect(clsMsgSender::strGetLocalIP(), muint16Port);
                      }
                      if ( mpsckClient->state() != QAbstractSocket::ConnectedState ) {
                          continue;
                      }
                  }
                  if ( blnAnythingToDo(objJSON) != true ) {
              //Nothing to do...yet!
                      continue;
                  }
              //Look for a module name in the message
                  QJsonObject::iterator itrFound = objJSON.find(clsJSON::mscszMsgType);
          
                  if ( itrFound != objJSON.end() ) {
                      const QJsonValueRef crobjMsgType = itrFound.value();
                      QString strMsgType(crobjMsgType.toString());
          
                      if ( strMsgType.compare(clsJSON::mscszAck) != 0 ) {
              //Insert a unique message ID into the message
                          objJSON.insert(clsJSON::mscszMsgID, QString::number(++clsMsgSender::msulnglngMsgID));
              //Create entry to monitor status of this message
                          new clsMsgTrkr(this, objJSON);
                      }
                  }
              //Writes message to socket
                  emit write(objJSON);
              }
          }
          
          1 Reply Last reply
          0
          • Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            Why do you think that clazy now magically is fixed without any other changes and asking the same question as 4 days ago?
            https://forum.qt.io/topic/121934

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            SPlattenS 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              Why do you think that clazy now magically is fixed without any other changes and asking the same question as 4 days ago?
              https://forum.qt.io/topic/121934

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

              @Christian-Ehrlicher , I was hoping since this is the latest offering, that someone could confirm that this is a Qt issue and not my own?

              Is there a way to role back to an earlier version of Qt Creator?

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

                I have now uninstalled Qt Creator 4.14 and 5.15.2 and switched to Qt Creator 4.13.1 using 5.15.1 and SDK 5.12.10.

                All the faulty messages have now disappeared.

                JonBJ 1 Reply Last reply
                1
                • SPlattenS SPlatten

                  I have now uninstalled Qt Creator 4.14 and 5.15.2 and switched to Qt Creator 4.13.1 using 5.15.1 and SDK 5.12.10.

                  All the faulty messages have now disappeared.

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

                  @SPlatten
                  Well done! Now be sure to switch off any "auto-update" of Creator! :)

                  SPlattenS 2 Replies Last reply
                  1
                  • JonBJ JonB

                    @SPlatten
                    Well done! Now be sure to switch off any "auto-update" of Creator! :)

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #8
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @SPlatten
                      Well done! Now be sure to switch off any "auto-update" of Creator! :)

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

                      @JonB , how?

                      mrjjM 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @JonB , how?

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        @SPlatten
                        hi

                        1 Reply Last reply
                        3

                        • Login

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