简体   繁体   中英

Change QT layout background

Since QVBoxLayout has no a setStylesheet method, I thought this would made the trick:

QWidget *window = new QWidget(this);
window->setStyleSheet("background-image:url(:/images/sky.jpg);font-size:18px;");
QVBoxLayout * layout = new QVBoxLayout(window);
layout->addWidget(widg1);
layout->addWidget(widg2);
setLayout(layout);

Sadly, only a small rectangle of background image appears, not covering entire window. How could I do it?

You can set stylesheet to the central widget of your main window. In the example you can put window into some other layout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM