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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.