简体   繁体   English

Qt自定义窗口

[英]Qt Custom Window

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? 在Qt中是否可以创建一个无边框但可以拖动而不按住Alt键的自定义窗口? I created a borderless window but in order to be able to drag it (on Linux) you have to hold down the alt key. 我创建了一个无边界的窗口,但是为了能够拖动它(在Linux上),您必须按住alt键。

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. 虽然,我认为实现mouseMove,mousePress或其他方法是可行的解决方案,但我需要其他解决方案。

Thanks 谢谢

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 (ie you must handle the mouse click+move events yourself). 如果没有拖动栏,则您的应用程序必须通过设置新位置来移动窗口本身(即,您必须自己处理鼠标的click + move事件)。

The feature to move the window by pressing Alt is also a function of your window manager, not Qt. 通过按Alt键移动窗口的功能也是窗口管理器的功能,而不是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. 基本上,您需要像Aaron所说的那样自己管理鼠标单击。

您可以使用QDecoration(对于嵌入式Linux)来实现: 这是示例

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. 当用户释放鼠标按钮时,您的任务就结束了。

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

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