如何将菜单栏和工具栏添加到Qdialog中

发布于 2025-01-22 00:23:02 字数 347 浏览 2 评论 0原文

存在任何解决方案如何将菜单或工具栏添加到Qwidget对话框中?

我制作类似ERP系统的东西。有许多Windows从其他Windows开口。重要的是,一个(父)窗口在孩子窗口中等待选择。在Chidren窗口中,有时我需要工具栏和菜单栏...

问题是,

  • 新的Child QmainWindow没有EXEC()函数。它导致父窗口不等待完成孩子的选择。
  • 新的孩子Qdialog没有菜单或收费栏。

是否存在任何解决方案(没有事件)?解决方案如何将菜单或工具栏添加到qdialog,或者解决方案如何使用等待模式mymainwindow-> exec()打开新的qmainwindow?

Exists any solution how to add menu or tool bar into the QWidget dialog?

I making something like ERP system. There are many windowses opening from others windowses. It's important that one (parent) window waiting for choices in children window. And in the chidren window sometimes I need toolbars and menu bars...

Problem is, that

  • new child QMainWindow have no exec() function. It cause that parent window no waiting for finishing choices in the child.
  • new child QDialog have no menu or toll bar.

Exists any solution (without events)? Solution how to add menu or tool bar to QDialog, or solution how to open new qmainwindow with waiting mode myMainWindow->exec()?

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

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

发布评论

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

评论(1

违心° 2025-01-29 00:23:02

好的。我找到解决方案。
我使用了qdialog。菜单或标签栏将添加为:
Anylayout-> addwidget(Tabbar);anylayout-> setMenubar(tabbar);

thx for Chris Kawa的答案:
不同之处在于,setMenubar将小部件放置在布局内容之外,因此布局的顶部边缘在栏下方。使用AddWidget,将栏作为布局内容添加,因此它尊重边缘(由SetContentsMargins控制)。
对于菜单和工具栏,我们通常希望它们坚持没有间隙的边缘,因此SetMenubar方法更适合于此。

Ok. I find solution.
I used QDialog. Menu or tab bar will be added as:
anylayout->addWidget(tabbar); or anylayout->setMenuBar(tabbar);

Thx for answer by Chris Kawa:
The difference is that setMenuBar places the widget outside of the layout content, so the top margin of the layout is below the bar . With addWidget the bar is added as a layout content, so it respects the margins (controlled by setContentsMargins).
For menus and toolbars we usually want them to stick to edges without a gap, so the setMenuBar method is more appropriate for it.

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