And*_*w T 20 pyqt dwm windows-vista aero-glass
有关使用Qt和DWM的示例,请参阅在Windows上使用Blur Behind.替代文字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()
Run Code Online (Sandbox Code Playgroud)
您可以立即单击该窗口,也可以单击Alt-Tab几次.
无论如何,使用带有Aero Glass的标签并不是我所需要的,因为QLabel不知道如何用一缕光线(如窗口的标题)来绘制自己.我需要的是清洁"玻璃"的一般方法.
只需使用:
QPainter p
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(boundsRect, QColor(0, 0, 0, 0));
Run Code Online (Sandbox Code Playgroud)
这会丢弃旧内容并填充透明色.
更多信息在
http://techbase.kde.org/Development/Tutorials/Graphics/Performance#QPixmap::setAlphaChannel.28.29
http://doc.qt.digia.com/qtjambi-4.4/html/com/trolltech/qt/gui/QPainter.CompositionMode.html
编辑:更好地使用CompositionMode_Clear并使用任何颜色绘制矩形.
| 归档时间: |
|
| 查看次数: |
8002 次 |
| 最近记录: |