Qt 自定义窗口
请原谅我,我是一个新手:)
在 Qt 中是否可以创建一个没有边框的自定义窗口,但仍然可以在不按住 Alt 键的情况下拖动?我创建了一个无边框窗口,但为了能够拖动它(在 Linux 上),您必须按住 alt 键。
我打算创建一个带有圆角的窗口。任何人都知道如何使这成为可能?虽然,我认为实现 mouseMove、mousePress 或其他东西是一个可能的解决方案,但我需要一些其他解决方案。
谢谢
Pardon me, I am a newbie :)
Is it possible in Qt to create a custom window without borders but still draggable without holding down the Alt Key? I created a borderless window but in order to be able to drag it (on Linux) you have to hold down the alt key.
I was planning to create a window with rounded corners. Any one have any idea how to make this possible? Although, I think implementing the mouseMove, mousePress or something is a possible solution but I need some other solution.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只有一种方法可以使窗口管理器移动窗口:添加拖动栏。如果没有拖动栏,那么您的应用程序必须通过设置新位置来移动窗口本身(即您必须自己处理鼠标单击+移动事件)。
通过按 Alt 来移动窗口的功能也是窗口管理器的功能,而不是 Qt 的功能。
There is just one way to make the window manager move the window: Add a drag bar. If there is no drag bar, then your app must move the window itself by setting the new position (i.e. you must handle the mouse click+move events yourself).
The feature to move the window by pressing Alt is also a function of your window manager, not Qt.
是的,有一个圆形窗口示例使用时钟来执行此操作。基本上,正如亚伦所说,您需要自己管理鼠标点击。
Yes, there is a rounded window example somewhere using a clock which does this. Basically, you need to manage the mouse clicks yourself as Aaron says.
您可以使用 QDecoration(适用于嵌入式 Linux)来制作:这里是示例。
You may use QDecoration (for Embedded Linux) to make it: here is the example.
检测到鼠标被按住在窗口上,然后捕获鼠标移动的事件,以便您可以与其同步移动窗口。当用户释放鼠标按钮时,您的任务就结束了。
Detect that the mouse is held down on your window, then grab the events for the mouse moving around so you can move your window in sync with it. When user releases mouse button your task is over.