I have a program which executes some process in main window and I need a modal dialog with some custom elements to be shown over it to show the progress. It also must block user interaction with main window. Main process should run while dialog is shown. Which way is better (in qt) for this purpose?
Asked
Active
Viewed 1.9k times
8
-
Better than what, the standard way? Have you already searched for alternatives? – Christian Rau Oct 27 '11 at 14:27
-
2Better is just another word for "best" or "standard". Please have some tolerance for non-native English speakers. We are trying our best. Thank you. – Mr. Developerdude Jun 26 '18 at 15:31
1 Answers
20
Actually, this sounds kinda easy (unless I misunderstand your question).
QDialog my_progress_dialog( this );
my_progress_dialog.setModal( true );
my_progress_dialog.show();
Calling show()
not exec()
will leave you in the main eventloop. At the same time, setting the dialog modal blocks all user input to the main window. Job done.
Have you looked at QProgressDialog
? It's there for exactly this purpose.

Robin
- 1,658
- 15
- 26
-
1Not even related to what I needed but you answered two questions for me Robin!!! TY! I didn't know there was a difference between show() and exec() until THIS! – Kris Kizlyk Feb 23 '21 at 20:29