PDA

View Full Version : How to close a Dialog from another class?



TCaruso33
17th September 2012, 20:11
Hello all,

I've created a function in my mainwindow class which opens a dialog.



Dialog.exec();


After this a dialog opens up with 4 push buttons. I want everyone of these push buttons to set a string then close the dialog. I was able to set the string but have no clue how to close the dialog from the dialog class. Any ideas?
I've seen some other threads mention signals and slots, but I still have no idea how that would be implemented. I would think I would run into the same situation (How would the dialog class know the signal was activated?).

Thanks in advance for your help.

Added after 10 minutes:

Nevermind, I've figured it out. But if anyone else has this issue here is what I did:



void Dialog::on_btn_clicked()
{
setString = "test";
QDialog::close();
}


I'm assuming the QDialog::close() command closes the current dialog (at least that is what it did for me).

wysota
17th September 2012, 20:18
Call close(), reject() or accept().