简体   繁体   English

更改QT布局背景

[英]Change QT layout background

Since QVBoxLayout has no a setStylesheet method, I thought this would made the trick: 由于QVBoxLayout没有setStylesheet方法,所以我认为这可以解决问题:

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. 在示例中,您可以将window置于其他布局中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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