QDialog类exec()与show()的区别

继承至QWidget的类都能使用show()将自身显示出来,QDialog也不例外。然而QDialog除了能使用继承至QWidget的show()方法显示自身之外,它还有另一个方法exec()同样也能将自身显示出来。那么这两个方法之间有什么区别呢?请看下面的表格对比:

原型返回值说明
void QWidget::show()Shows the widget and its child widgets.
int QDialog::exec()

Shows the dialog as a modal dialog, blocking until the user closes it. The function returns a DialogCode result. If the dialog is application modal, users cannot interact with any other window in the same application until they close the dialog. If the dialog is window modal, only interaction with the parent window is blocked while the dialog is open. By default, the dialog is application modal.

从表格对比中可以看出这两者的区别。首先这两个方法返回值不同。exec()有返回值,show()没有返回值。其次这两个方法的作用也不同。调用show()的作用仅仅是将widget及其上的内容都显示出来。而调用exec()后,调用线程将会被阻塞,直到Dialog关闭。

转载于:https://www.cnblogs.com/xiaojihua20/p/4108665.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值