Reputation: 18918
How should I best go about forcing a QDialog to stay open when the dialog's accept()
slot is called? I was thinking of reimplementing that function to get the dialog's exec to return without hiding the dialog, but was wondering if there were any better ways to accomplish this.
Upvotes: 1
Views: 1441
Reputation: 29896
You need to make your QDialog
modeless, by calling show
instead of exec
, and using a custom signal instead of accept
, because accept
closes the window. And you connect that signal to a slot in the main window with the code you had after the exec
call.
And in case that wasn't already the case, you should keep a reference/pointer to your QDialog somewhere (as a member in your main window class, or a static variable within the function that opens it) to be able to avoid creating multiple instances of the dialog, and you need to make sure you only connect the signals/slots once.
Upvotes: 2
Reputation: 1129
Rather than use a QDialog, I would accomplish the effect with a QDockWidget.
References
Upvotes: 2