Reputation: 4480
I am facing one issue while applying background image to QT form. The image which i am applying to bg contains some gradient effect but after applying to background its gradient affect is going.
I am using below code at run time for applying bg image :
QPalette palette;
palette.setBrush(this->backgroundRole(), QBrush(QImage("bg_all.png")));
this->setPalette(palette);
Upvotes: 1
Views: 4218
Reputation: 1904
If you just want to add a background to a form, why not set one using a stylesheet instead?
For example:
widget->setStylesheet("background-image: url(:/files/bg.png);")
Upvotes: 2
Reputation: 2406
QPalette palette;
QString appDir = QApplication::applicationDirPath();
palette.setBrush(this->backgroundRole(),QBrush(QImage(appDir +"/bg.png")));
this->setPalette(palette);
That is fine for me. Please check the file path is correct or not.
Upvotes: 2