Mac 上的 Qt 默认按钮

发布于 2024-10-04 11:50:52 字数 128 浏览 0 评论 0原文

Mac 能够指定两个默认按钮,一个通过回车键激活,另一个通过空格键激活。一个明显的例子是当您按下 Mac 上的电源按钮时。它为您提供了一个带有几个安静按钮的对话框,其中默认使用返回键关闭,默认使用空格键重新启动。 Qt中可以实现这样的效果吗?

Mac have a capability to specify two default buttons, one activated by return and other by spacebar. One clear example is when you press power button on mac. It gives you a dialog box with quiet a few buttons, in which it shutdown is default for return key and restart is default for spacebar key. Is it possible to achieve such effect in Qt?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思故 2024-10-11 11:50:52

是的。

使用QPushButton。在“默认”按钮上使用 setDefaultsetAutoDefault() 使它们显示为默认按钮。

http://doc.trolltech.com/4.7/qpushbutton.html#default-prop

要处理退出键(甚至可能是返回键),您必须为每个按钮设置快捷键,以将它们与相应的键关联起来。使用 Qt Creator/Designer 可以轻松做到这一点。

Yes.

Use QPushButton. On the "default" button use setDefault and setAutoDefault() to make them appear as a default button.

http://doc.trolltech.com/4.7/qpushbutton.html#default-prop

To handle the escape key (and possibly even the return key), you must set the shortcuts for each button to associate them with a corresponding key. It's easy to do that using Qt Creator/Designer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文