很简单直接上代码:
#include
<
dwmapi.h
>
//
DWM APIs
#pragma comment(lib, " dwmapi " ) // DWM library
class MainWindow : public QMainWindow
{
public :
MainWindow()
{
QPushButton * b = new QPushButton( " click me! " , this );
MARGINS mar = { 40 , 40 , 100 , 100 }; // left, right, top, bottom margins.
DwmExtendFrameIntoClientArea ( this -> winId(), & mar ); // set the margins
}
void paintEvent ( QPaintEvent * event )
{
QPainter p( this );
p.setCompositionMode(QPainter::CompositionMode_DestinationIn); // it's necessary!
QRect rc = this -> rect();
p.fillRect(rc, QColor( 0 , 0 , 0 , 0 )); // the RGB color is not the point, the alpha value is.
}
};
int main( int argc, char * argv[])
{
QApplication app(argc, argv);
MainWindow mw;
mw.show();
app.exec();
}
#pragma comment(lib, " dwmapi " ) // DWM library
class MainWindow : public QMainWindow
{
public :
MainWindow()
{
QPushButton * b = new QPushButton( " click me! " , this );
MARGINS mar = { 40 , 40 , 100 , 100 }; // left, right, top, bottom margins.
DwmExtendFrameIntoClientArea ( this -> winId(), & mar ); // set the margins
}
void paintEvent ( QPaintEvent * event )
{
QPainter p( this );
p.setCompositionMode(QPainter::CompositionMode_DestinationIn); // it's necessary!
QRect rc = this -> rect();
p.fillRect(rc, QColor( 0 , 0 , 0 , 0 )); // the RGB color is not the point, the alpha value is.
}
};
int main( int argc, char * argv[])
{
QApplication app(argc, argv);
MainWindow mw;
mw.show();
app.exec();
}