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 . 0_1565173691140_1.JPG

    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);


  • @maniron

    With stylesheet:

    QString stylesheet = QString("QMainWindow { border-image: url(%1) 0 0 0 0 stretch }").arg(YOUR_IMG_PATH);

Log in to reply