简体   繁体   English

窗口标题Qt中的小部件

[英]Widgets in window title Qt

Is in Qt something like GTK.headerbar or any other possibility to add wiget (button for example) in window title? Qt中是否有GTK.headerbar之类的东西,或在窗口标题中添加了wiget(例如按钮)的任何其他可能性?

Thanks in advance. 提前致谢。

Short answer is 'no', Qt doesn't implement any kind of window decorations (except QWS which is a different story). 简短的回答是“不”,Qt不实现任何类型的窗口装饰(QWS除外)。

In Linux the title bars (window decorations) are carried by Window Managers, like Metacity or Compiz. 在Linux中,标题栏(窗口装饰)由窗口管理器(如Metacity或Compiz)承载。 Windows and OSX use their own window decorations. Windows和OSX使用它们自己的窗口装饰。 Qt has almost no control over what happens on the window title bars. Qt几乎无法控制窗口标题栏上发生的事情。

Gnome3/GTK3 (and not Gnome2) allows you to use widgets in the title bar but it's not the case for many other Desktop Environments / Window Managers. Gnome3 / GTK3(而不是Gnome2)允许您使用标题栏中的小部件,但其他许多桌面环境/窗口管理器则不是这样。 Your options are: 您的选择是:

  • Use the API provided by the window manager / OS 使用窗口管理器/操作系统提供的API
    • Pros: native look. 优点:本机外观。
    • Cons: you need to maintain separate implementation for each OS / DE. 缺点:您需要为每个OS / DE维护单独的实现。 Not all support doing such. 并非所有人都支持这样做。
  • Hide window decorations and implement you own 隐藏窗口装饰并实现您自己的
    • Pros: code once, use everywhere. 优点:只需编写一次代码,就可以在任何地方使用。 Google Chrome and Vivaldi do that, for example. 例如,谷歌浏览器和维瓦尔第就是这样做的。
    • Cons: you need to implement window resize and move 缺点:您需要实现窗口大小调整和移动
  • Use an overlay widget on top of the system title bar that will always follow the window 使用系统标题栏顶部的覆盖小部件,该小部件将始终紧随窗口
    • Pros: pretty much straightforward to do but I don't recommend it. 优点:做起来很简单,但我不建议这样做。
    • Cons: the widget will always lag when moving the main window. 缺点:小部件在移动主窗口时将始终滞后。 Native look still has to be implemented. 本机外观仍然必须实现。 Take into account that user can switch the theme and the widget will look odd. 考虑到用户可以切换主题,并且小部件看起来很奇怪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM