Unsolved Signals and Slots not connecting
-
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
-
@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.