Unsolved How to set a full background for the main widget
-
I am trying to set a full background image for my mainwindow but it is not fitting fully .
Like the image which i have attached . Kindly say how to set a full scaled image as a background for my mainwindow
My code :
QPixmap bkgnd("" + QDir::currentPath() + "./Images/9.jpg"); bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio); QPalette palette; palette.setBrush(QPalette::Background, bkgnd); this->setPalette(palette);
-
With stylesheet:
QString stylesheet = QString("QMainWindow { border-image: url(%1) 0 0 0 0 stretch }").arg(YOUR_IMG_PATH); this->setStylesheet(stylesheet);