Use Qt to draw profiled forms and use qt to draw profiled forms.
The special form is an irregular form. Generally, png images are used. Generally, the special form is drawn in two steps:
1. Set the mask area
2. Draw Images
Use the transparent part of the png image as the mask area, and then draw the image, so that we can see a graph that only draws the non-transparent part, for example, to draw a butterfly (Butterfly is translucent), the effect is as follows:
1: #include <QWidget>
2: class TransDialog : public QWidget
3: { 4: Q_OBJECT
5: public:
6: explicit TransDialog(QWidget *parent = 0);
7: void paintEvent(QPaintEvent *event) ;
8: private:
9: QPixmap m_Pixmap;
10: };
11:
Cpp file:
1: #include "transdialog.h"
2: #include <QBitmap>
3: #include <QPalette>
4: #include <QPaintEvent>
5:
6: TransDialog::TransDialog(QWidget *parent) :
7: QWidget(parent,Qt::FramelessWindowHint)
8: {9: // make the program background translucent
10: this->setWindowOpacity(0.5);
11: // load a transparent image in some areas as a program interface
12: m_Pixmap.load("hudie.png"); 13: resize(640, 480);
14: // keep the image as the page size
15: m_Pixmap = m_Pixmap.scaled(size());
16: // set Automatic Filling
17: setAutoFillBackground(true);
18:
19: // key to the irregular window. Set the transparent area of the image as the penetrating area.
20: setMask( m_Pixmap.mask() );
21:
22: }
23:
24: void TransDialog::paintEvent(QPaintEvent *event)
25: {26: // draw the background image
27: QPalette bgPalette = this->palette();
28: bgPalette.setBrush(QPalette::Background,m_Pixmap);
29: this->setPalette(bgPalette);
30: }