Mac Os X 中类似 Windows 的 Qt4 菜单栏

发布于 2024-08-09 16:24:45 字数 172 浏览 10 评论 0原文

我希望我的应用程序看起来与 Windows 版本的应用程序类似:我希望我的程序将文件菜单放在应用程序本身的顶部,而不是将菜单移至 Os X 中的顶部菜单。

我查看了与此相关的 Qt 文档,但我似乎无法创建一个空的 QMenuBar 作为顶级 QMenuBar。 (我正在使用 QMainWindow 的子类...)

I would like my application to look similar to that of the Windows version: instead of the menu being displaced to the top menu in Os X, I'd like my program to have the file menu right on top of the application itself.

I've looked at the Qt documentation regarding this, but I can't seem to create an empty QMenuBar as the top level QMenuBar. (I'm using a subclass of QMainWindow...)

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

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

发布评论

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

评论(3

染火枫林 2024-08-16 16:24:45

这是一个坏主意,不会赢得 Mac 社区中的应用程序粉丝。 这里是 Apple 人机界面指南。

This is a bad idea and will not win your application fans in the Mac community. Here are the Apple Human Interface Guidelines.

呢古 2024-08-16 16:24:45

他为什么要这么做?多个显示器,这就是原因。必须将鼠标从您正在使用的显示器移回到主显示器以访问菜单栏,然后​​一直回到您所在的显示器,这真是太痛苦了。我认为如果更多的话那就太棒了Mac 应用程序至少可以选择将其菜单直接放置在应用程序窗口中。

Why would he want to do this? Multiple Monitors, that's why. Complete pain in the keester to have to move your mouse from the monitor you are working in back to the main monitor to access the menu bar and then all the way back over to the monitor you were in. I think it would be FANTASTIC if more mac apps at least had the option to place their menu directly in the application window.

泪是无色的血 2024-08-16 16:24:45

您创建的第一个菜单栏将成为 Mac 主菜单栏。您可以在创建 QApplication 后立即尝试创建一个虚拟应用程序。您可能需要至少在其中放置一个退出命令。

或者,您可以使用 Qt::AA_DontUseNativeMenuBar 调用 QApplication::setAttribute。不过,我不知道在这种情况下 Mac 菜单栏会填什么。

The first menubar you create becomes the main mac menubar. You could try creating a dummy one immediately after you create the QApplication. You might want to put at least a quit command in there.

Alternatively, you can call QApplication::setAttribute with Qt::AA_DontUseNativeMenuBar. I don't know what will fill the mac menubar in that case, however.

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