Create a window in qt with a form from an image

Can someone explain to me how to make a window in qt in accordance with the shape of any object in the image, for example, I have a tree image, using this, I need to create a tree-shaped window ..

+5
source share
3 answers

After a long search, I found a good solution, check out this.

#include <QtGui>
 class  myMainWindow:public QMainWindow
 {
 public:
     myMainWindow():QMainWindow()
     {
    setMask((new QPixmap("saturn.png"))->mask());


    QPalette* palette = new QPalette();
    palette->setBrush(QPalette::Background,QBrush(QPixmap("saturn.png")));
    setPalette(*palette);   

    setWindowFlags(Qt::FramelessWindowHint);     
    QWidget *centralWidget = new QWidget(this);
    QGridLayout *layout = new QGridLayout();

    centralWidget->setLayout(layout);

    QPushButton* button1 = new QPushButton("Button 1");
    button1->setFixedSize(80,50);

    layout->addWidget(button1,0,0); 

    setCentralWidget(centralWidget);

     };
     ~myMainWindow(){};
 };

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    myMainWindow *window = new myMainWindow();    

    window->resize(600, 316);          
    window->show();
    return app.exec();
}
+4
source

- . , , . , - , , , , - .

+2

QWidget::setMask. , QBitmap , QRegion. . QRegion - , , .

0

All Articles