Solved Beginner question: How to tell when Dialog is exposed?
-
@mstoth
use signal slot mechanism.Dialog *dialog = new Dialog; connect(dialog, &Dialog::rejected, this, [=](){ //something }); dialog->show();
or in your Dialog class listen a closeEvent:
void Dialog::closeEvent (QCloseEvent *event) { emit closed(); event->accept(); }
.h file:
signals: void closed(); protected: void closeEvent(QCloseEvent *event);
Dialog *dialog = new Dialog; connect(dialog, &Dialog::closed, this, [=](){ //something }); dialog->show();
-
This post is deleted! -
@Taz742 said in Beginner question: How to tell when Dialog is exposed?:
connect(dialog, &Dialog::rejected, this, =
Hi, why
rejected
? -
@Diracsbracket
When form 'X' button click, when a dialog is closed QDialog does not call a rejected signal ? -
@Taz742 said in Beginner question: How to tell when Dialog is exposed?:
When form 'X' button click, when a dialog is closed QDialog does not call a rejected signal
Yes, but when you reject a config dialog, then that usually means nothing needs to be done...? I would have used the
accepted()
signal. But hey, let's wait and see what exactly @mstoth has in mind. -
@Diracsbracket
I think no one is right, he only wants to hide the dialog? Waiitt )) -
@Taz742 said in Beginner question: How to tell when Dialog is exposed?:
he only wants to hide the dialog
@mstoth said in Beginner question: How to tell when Dialog is exposed?:
when that second panel goes away, my first dialog needs to check a parameter
I think he wants to check if any of the settings were changed when the dialog was closed^^. In any case, thanks for posting the solution!
-
Indeed, all I need to do is see if something has happened when the first dialog is visible again. I thought about signals/slots but there is more than one case where this first dialog becomes visible again. For instance, the first dialog has 6 buttons, each presents a different new dialog. When any of those appear, they hide the first one. To use signals, i'd have to connect to each of those 6 dialogs.
I was hoping for something more elegant like a event handler I could override in the first dialog that gets called when the first dialog becomes visible again. (something like onExposed()) . I have not seen anything like that.
Thanks by the way for all the help! I appreciate your thoughts.
-
@mstoth
Good! I think you have an idea of what to do. Then mark this topic to be solved. -
ok, so my solution is to use signals to indicate the condition i'm interested in. It's a bit messy since there are so many places I need to connect to but from what I'm hearing, that is the only way.
I'll mark it as solved but unfortunately it is not the kind of solution I was hoping for. If anyone else has a more elegant way of handling this feel free to let me know.
I do appreciate everyone's time and effort on this problem! Thank you very much.