QDialog 弹出另一个 QDialog
我有一个子类 QDialog,其中包含一堆子类 QSpinBox。单击旋转框时,会出现一个键盘(另一个 QDialog),您可以在其中使用按钮输入数字。两个 QDialog 都是通过调用 QDialog::exec() 来激活的;
但是,当打开第二个 QDialog 时,第一个 QDialog 将关闭。我已经完成它并注意到第一个 QDialog 尚未结束。 QDialog 1 在完成 QDialog 2 后发出“QDialog::Rejected”。我想要的是 QDialog 1 根本不结束,它需要使用输入的值更新旋转框,并为其他旋转框打开更多 QDialog用户想要稍后编辑。
我认为这与 QDialog 1 的事件循环被 QDialog 2 的事件循环杀死有关。我尝试过在 QDialog 2 上使用 QDialog::show 。小部件会弹出一会儿(毫秒),但不会保持活动状态。 QDialog 1 也立即关闭。
I have a subclassed QDialog containing a bunch of subclassed QSpinBox's. When clicking a spinbox, a keypad (another QDialog) where you can use pushbuttons to enter digits. Both QDialog's are activated by calling QDialog::exec();
However, when opening this 2nd QDialog, the first one closes down. I've stepped through it and noticed the 1st QDialog doesn't end yet. QDialog 1 sends out "QDialog::Rejected" AFTER I finish QDialog 2. What I'd want is the QDialog 1 not to end at all, it needs to update the spinbox with the entered value and open up more QDialog's for other spinbox's the user wants to edit later on.
I think it has to do with the QDialog 1's eventloop being killed by QDialog 2's eventloop. I've tried using QDialog::show on QDialog 2. The widget pops up for a moment (millisecond) but doesn't stay active. QDialog 1 is immediately closed as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
QDialog 1 默认设置为 Qt::Popup,QDialog 2 默认设置为 Qt::Dialog。弹出窗口会关闭各种事件。我也将 QDialog 2 的标志设置为 Qt::Popup ,这似乎不再关闭 QDialog 1 。
QDialog 1 is set to Qt::Popup, QDialog 2 was set to Qt::Dialog by default. A popup closes down on a wide range of events. I've set QDialog 2's flag to Qt::Popup as well, which doesn't seem to close down QDialog 1 anymore.
按照您口头描述代码的方式,您不应该看到您所描述的问题。如果没有看到您的实际代码,我无法冒险猜测导致问题的原因。但是,我可以肯定地说,我已经在对话框 A 上运行了 exec(),然后在对话框 B 上运行了 exec()(通过按钮),并且当对话框 B 退出时,对话框 A 保持可用。
The way you've verbally described the code, you shouldn't be seeing the problem you describe. Without seeing your actual code, I couldn't hazard a guess as to what is causing the problem. However, I can say with certainty I've run
exec()
on dialog A, then inside that runexec()
on dialog B (from a button), and had dialog A stay available when dialog B exits.