简体   繁体   English

调整半透明Qt小部件时的黑色闪烁(仅在启用Aero时)?

[英]Black flicker while resizing translucent Qt widget (only when Aero is enabled)?

I have a top-level Qt widget with the FramelessWindowHint flag and the WA_TranslucentBackground attribute set. 我有一个顶级的Qt小部件,其中包含FramelessWindowHint标志和WA_TranslucentBackground属性集。 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. 如果我禁用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. 我在一篇描述Qt新版本的文章中解释了这个问题的简要提及(这个版本已经很久了),但它仍然不起作用。

Any ideas why? 有什么想法吗?

Thanks! 谢谢!

I don't have experience with Qt specifically, but I have worked with other windowing toolkits. 我没有专门的Qt经验,但我使用过其他窗口工具包。 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. 如果你“幸运”,那么所有的更新都会在屏幕刷新之间发生,你可能看不到任何闪烁。

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

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