Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Signals and Slots not connecting

    General and Desktop
    2
    2
    86
    Loading More Posts
    • 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.
    • A
      aftershocker1 last edited by aftershocker1

      Hello, looking for a bit of help in the hope I have just made a small syntax error. I have a window that opens, the user enters some data as well as selecting a file path, then once the user submits it opens a new window. I need to get these three pieces of data to the new window so they can be used there. The data in entered and the emit function seems to have the correct data in it but the slot is not hit. It maybe to do with the way i have used the QObject::connect?

      in main.cpp

      //objects declared
      QtTestTool qttesttool;
      SPS2data sps2data;
      
      //connection
      QObject::connect(&qttesttool, &QtTestTool::userInputDataSignal, &manunoneng, &ManuNonEng::getUserDataSlot);
      
      

      in QtTestTool.cpp ( defined as a signal in the .h)

      emit userInputDataSignal(userName, userTemp, saveCSVpath);
      

      in manunoneng.cpp ( defined as a slot in the .h)

      void ManuNonEng::getUserDataSlot(QString userName, QString userTemp, QString saveCSVpath)
      {
      	userId = userName;
      	testTemp = userTemp;
      	savePath = saveCSVpath;
      }
      

      When debugging the code hits the emit, the data that is to be emitted is as it should be but the slot is never hit.

      Any suggestions would be great.

      Thanks

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @aftershocker1 last edited by JonB

        @aftershocker1 said in Signals and Slots not connecting:

        //objects declared
        QtTestTool qttesttool;
        SPS2data sps2data;

        Where are the these declared? As member variables in an instance which persists? I would expect those lines in the class declaration in the .h file, not in the .cpp file.....

        Your connect() looks good.

        1 Reply Last reply Reply Quote 1
        • First post
          Last post