调整半透明 Qt 小部件大小时出现黑色闪烁(仅当启用 Aero 时)?
我有一个顶级 Qt 小部件,带有 FramelessWindowHint 标志和 WA_TranslucentBackground 属性集。它有几个孩子,每个孩子都在上面画一个图像。它们不在布局中。相反,我只是在发生变化时移动它们(用户无法调整大小)。
窗口有两种状态 - 大状态和小状态。当我在它们之间切换时,我会调整窗口大小并重新定位子项。问题在于,当窗口大小调整时,在将图像绘制在其上之前,顶层窗口上会短暂闪烁一个黑框。
如果我禁用 Aero,问题就会消失。我发现在一篇描述 Qt 新版本的文章中简要提到了这个问题已被修复(这个版本已经过去很久了),但它仍然不起作用。
有什么想法吗?
谢谢!
I have a top-level Qt widget with the FramelessWindowHint flag and the WA_TranslucentBackground attribute set. It has several children, each of which draws an image on it. They are not in a layout. Instead, I simply move them around when something changes (it is not user-resizable).
There are two states to the window - a big state and a small state. When I switch between them, I resize the window and reposition the children. The problem is that as the window resizes, a black box is briefly flashed on the top-level window before the images are painted over it.
The problem goes away if I disable Aero. I found brief mention of this problem being fixed in an article describing a new release of Qt (this release is long past), but it still doesn't work.
Any ideas why?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有具体使用 Qt 的经验,但我使用过其他窗口工具包。通常,当您直接在屏幕上绘制更新时,您会看到这种闪烁。解决方法是使用 双缓冲,这基本上意味着您将更新渲染到屏幕外缓冲区(某种位图,从最纯粹的意义上来说),然后通过单个快速操作将整个更新的图像复制到屏幕。
有时您只能看到闪烁的原因只是屏幕刷新速度与更新绘制速度的影响。如果您“幸运”,那么所有更新都会在屏幕刷新之间发生,并且您可能不会看到任何闪烁。
I don't have experience with Qt specifically, but I have worked with other windowing toolkits. Typically you see this kind of flashing when you are drawing updates directly to the screen. The fix is to instead use Double buffering, which basically means that you render your updates into an offscreen buffer (a bitmap of some sort, in the purest sense of the word), and then copy the entire updated image to screen in a single, fast operation.
The reason you only see the flickering sometimes is simply an artifact of how quickly your screen refreshes versus how quickly the updates are drawn. If you get "lucky" then all the updates occur between screen refreshes and you may not see any flicker.