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()
#include <QtGui>#include <atlbase.h>#include <uxtheme.h>void VistaGlass( int * );int main( int argc, char *argv[] ){ QApplication a( argc, argv ); QWidget w; QVBoxLayout *lyt = new QVBoxLayout(); QPushButton *bt = new QPushButton( "Push me!" ); QLabel *lbl = new QLabel( "Yahoo! I was do it!!!" ); lbl->setAlignment( Qt::AlignCenter ); w.setAttribute( Qt::WA_NoSystemBackground ); VistaGlass( ( int* )w.winId() ); w.setLayout( lyt ); w.show(); w.repaint(); w.resize( 300, 450 ); a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); return a.exec();}; void VistaGlass( int *Handle ) { HMODULE dwm = ::LoadLibrary( L"dwmapi.dll" ); if(dwm) { typedef HRESULT (WINAPI *pDwmExtendFrameIntoClientArea)(HWND, void * MARGINS); pDwmExtendFrameIntoClientArea procAddr = (pDwmExtendFrameIntoClientArea)::GetProcAddress(dwm, "DwmExtendFrameIntoClientArea"); if(procAddr) { MARGINS a = {0,0,1000,0}; HRESULT hr = (procAddr) ((HWND)Handle,&a); } ::FreeLibrary(dwm); } };