更新
有关使用 Qt 和DWM的示例,请参阅在 Windows 上使用模糊。替代文字 http://labs.trolltech.com/blogs/wp-content/uploads/2009/09/blurbehind2.png
原始问题:
我想用 Qt 创建一个 Windows Aero Glass 窗口,现在它看起来像这样:
但是在调用了一些之后,my_window->repaint()
我的窗口标签就坏了:
但现在如果我稍微调整窗口大小,它会正确重绘。
问题是:我如何擦除窗口背景,以便小部件将自己绘制在干净的玻璃上?
重现问题的简短代码是(Vista with Aero):
class Window(QWidget):
def __init__(self, *args):
QWidget.__init__(self, *args)
self.setLayout(QVBoxLayout())
self.layout().addWidget(QLabel("This is the text"))
# let the whole window be a glass
self.setAttribute(Qt.WA_NoSystemBackground)
from ctypes import windll, c_int, byref
windll.dwmapi.DwmExtendFrameIntoClientArea(c_int(self.winId()), byref(c_int(-1)))
def mousePressEvent(self, event):
self.repaint()
您现在可以单击窗口,也可以单击Alt-Tab
几次。
无论如何,使用带有 Aero Glass 的标签不是我需要的,因为 QLabel 不知道如何用一段时间发光(如窗口的标题)来绘制自己。我需要的是一种清洁“玻璃”的通用方法。