Qt 覆盖标题栏和菜单栏?
我开始了一个一直在计划的项目,我有一个简单的问题。
我希望拥有尽可能多的屏幕空间。为此,我需要使标题栏变薄,并且我还想让菜单栏隐藏,直到将其悬停在其上。
是否有一个功能可以快速缩小标题栏。
我很确定我需要使用 setMenuWidget() 创建自定义菜单栏,然后添加标签、信号和其他有趣的菜单内容。我说得对吗,除了设置所有标签和连接的函数之外,我还需要 setMenuWidget() 吗?我是否必须在类中创建一个变量,或者我可以创建一个名为 setUpMenuBar() 的函数吗?
我试图尽我所能地表达这一点。有时我的问题有点模糊,所以如果你清楚的话,就问吧。
谢谢!
I started on a project that I've been planning and I have a quick question.
I want to have as much screen space as possible. To do this I need to make the title bar thinner and I also want to have the menu bar hide until it is hovered over.
Is there a function that would allow be to quickly just shrink the title bar.
I'm pretty sure I need to use setMenuWidget() to create a custom menu bar, and then just add the labels, signals, and the other fun menu stuff. Am I right, is setMenuWidget() all I need beside the function that sets all of the labels and connections? Would I have to create a variable in the class, or could I just create a function called setUpMenuBar()?
I tried to word this as well as I could. Sometimes my questions are a bit vague so if you clarity, just ask.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用全屏模式摆脱标题栏。我认为这比看起来不标准的细标题栏更加用户友好。
Use full screen mode to get rid of the title bar. I think that would be much more user friendly than a nonstandard looking thin title bar.
您的自定义菜单栏小部件是否需要成员变量仅取决于您对它的使用。如果您所做的只是创建菜单,那么不,您不需要为其保留成员变量。 “QMainWindow 获得了 menuBar 指针的所有权,并在适当的时间将其删除。”
您甚至可以稍后检索指向菜单栏的指针:
如果您更频繁地需要此指针,您可以重写 MyMainWindow::menuWidget() 或将该指针保存为成员。
Whether or not you need a member variable for your custom menu bar widget depends only on your use of it. If all you do is create the menu, then no, you don't need to keep a member variable for it. "QMainWindow takes ownership of the menuBar pointer and deletes it at the appropriate time."
You can even retrieve a pointer to menubar later:
If you need this pointer more often, you can either override MyMainWindow::menuWidget() or save the pointer as a member.