Qt模态对话框和主流程
我有一个在主窗口中执行某些进程的程序,我需要一个模式对话框,其中显示一些自定义元素以显示进度。它还必须阻止用户与主窗口的交互。显示对话框时应运行主进程。 对于这个目的,哪种方法更好(在qt中)?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,这听起来很简单(除非我误解了你的问题)。
调用
show()
而不是exec()
将使您处于主事件循环中。同时,设置对话框模式会阻止所有用户输入到主窗口。工作完成了。你看过
QProgressDialog
吗?它正是为了这个目的而存在的。Actually, this sounds kinda easy (unless I misunderstand your question).
Calling
show()
notexec()
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.