Unsolved how to add the image from resource file for background of the mainwindow
-
I want to add thge background image of QMainwindow and i want to add from the QRC file how can this be done ?
-
Image File should be in your qrc file
Do this in your constructorMainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QPixmap bkgnd("qrc:/images/xyz.png"); // rightt click on image in qrc to copy its path bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio); QPalette palette; palette.setBrush(QPalette::Background, bkgnd); this->setPalette(palette); }
For details have a look at this answer:How do I add a background image to the QMainWindow?
-
@racerXali i did it but the image is not displaying . Whether it works only when we create an exe
-
Hi,
Isn't this the same question as here ?
-
Hi
Right click the image and select the :/ syntax and see if that helps.