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. Signals and Slots not connecting
Forum Updated to NodeBB v4.3 + New Features

Signals and Slots not connecting

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 182 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.
  • A Offline
    A Offline
    aftershocker1
    wrote on last edited by aftershocker1
    #1

    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

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

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

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

      • Login

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