Connecting QDialog to QMainWindow
I have created a QMainWindow using QT Designer. I have components that have signals slots. I've made some non-gui components QObjects so I can also use the signal/slot mechanism.
My next step was to add a modeless dialog. I do not want the dialog to block the main window. I would like the dialog to remain active(somewhere visible to the user or in the background) until the user clicks to close it. I created a modeless QDialog object with designer. The dialog pops up as needed. It keeps the information from the previous session in the text box as well. It's just a filename.
However, when I started to connect the QDialog to the QMainWindow, the signal/slot mechanism does not appear to work.
This is my code:
//In the .h file declared as member of the QMainWindow
ScriptDialog *theScriptDialog;
//In the .cpp file, the constructor of QMainWindow
theScriptDialog = new ScriptDialog(this);
QObject::connect(theScriptDialog, SIGNAL(notifyStartScript(QString)), SLOT (startScripting(QString)));
Maybe I am barking up the wrong tree. Is there a better way to create a pop up window like this?
First see if the connect succeeds: check applications console output for a warning about failed connect, then print return value of connect call.
Then some things to do:
Q_OBJECT
macro in scriptdialog.h Q_OBJECT
classes qDebug
print/breakpoint to where notifyStartScript
is emitted startScripting
slot, with qDebug
print or breakpoint, to verify it gets called