Ok, so I have the background image in a resource file.
I have a widget as main window and on top of that, a MultiPageWidget. ( all built with the designer ).
Now, using a stylesheet I haven't managed to set the window ( widget ) background so that the surrounding multipagewidget`s area ( the visible place belonging to the main window widget that is behind ) would have the specified background-image.
After trying all the possibilities, I found a workaround... actually not a workaround... just something to make it work :P and it involves the following code, and not css ( what I wanted ).
QPixmap bg
(":/images/background.png");
setAutoFillBackground(true);
setPalette(p);
QPixmap bg(":/images/background.png");
QPalette p(palette());
p.setBrush(QPalette::Background, bg);
setAutoFillBackground(true);
setPalette(p);
To copy to clipboard, switch view to plain text mode
This is quite a standard way of setting an image for background, but I wanted the clean css way, not the coded way...
p.s.: This way It had a nice side-effect by displaying the background image trough the other controls like QGroupBox and QLabel that were contained in the MultiPageWidget. I expected them being opaque instead of transparent, but that will do.
The CSS I used in trying to set the background image was simple:
MainWindow {
background-image: url(:/images/background.png);
}
MainWindow {
background-image: url(:/images/background.png);
}
To copy to clipboard, switch view to plain text mode
If I use a background-color: red; for example... I get the desired effect, only with a color, not an image.
Hope I was explicit enough.
Any ideeas?
Bookmarks