开发者

Ovveride, the paintevent of the Qwidget

开发者 https://www.devze.com 2022-12-29 22:55 出处:网络
I want to put a back开发者_StackOverflow中文版ground image in mt QWidget, can anyone help me on

I want to put a back开发者_StackOverflow中文版ground image in mt QWidget, can anyone help me on this.

how to Ovveride, the paintevent of the Qwidget and draw a image there


Here is what you need:

#include <QApplication>
#include <QGridLayout>
#include <QWidget>

int main(int argc, char ** argv)
{
    QApplication app( argc, argv );

    QWidget widget(0);
    widget.setStyleSheet("background-image: url(1.PNG)");

    QGridLayout *leftLayout = new QGridLayout();
    leftLayout->setSpacing (0);

    widget.setLayout(leftLayout);  

    widget.show(); 
    return app.exec();
}

Where 1.PNG is the image located in the same directory with the app.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号