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.
精彩评论