Qt-interest Archive, June 2007
Qt 4.3 can't style QMainWindow with stylesheet
Message 1 in thread
Hi. I am new to this list.
And I already have a problem..
I recently compiled Qt 4.3 (coming from Qt 4.2) and the background image of
my application stopped working.
I can't get it back anymore.
I used this stylesheet in 4.2:
QMainWindow {
background: white url(img/altbg.png);
background-repeat: repeat-x;
margin: 0px;
spacing: 0px;
padding: 0px; }
But it seems like QMainWindow can't be styled in 4.3. Then I tried:
QWidget#nameOfMainWindow, but that also didn't work because it is a
QMainWindow and no QWidget (eventhough QMainWindow inherits QWidget).
Just styling QWidget is no help either, because then everything gets the
background image, not just the QMainWindow.
Any ideas on how I can work around the issue? Or is a solution available
already in one of the development releases?
Thanks,
--
[ signature omitted ]
Message 2 in thread
2007/6/18, Wesley S. <wesley@xxxxxxxxxx>:
>
>
> But it seems like QMainWindow can't be styled in 4.3. Then I tried:
> QWidget#nameOfMainWindow, but that also didn't work because it is a
> QMainWindow and no QWidget (eventhough QMainWindow inherits QWidget).
> Just styling QWidget is no help either, because then everything gets the
> background image, not just the QMainWindow.
>
> Any ideas on how I can work around the issue? Or is a solution available
> already in one of the development releases?
> <http://wesley.debianbox.be>
I found a _temporary_ solution, but it is suboptimal and not 100% foolproof.
I use this to set the background for all child QWidgets of QMainWindow:
QMainWindow > QWidget {
background: white url(img/altbg.png);
background-repeat: repeat-x;
margin: 0px;
spacing: 0px;
padding: 0px; }
and I use this to set the background to white (and remove the background
image) for messageboxes, dialogs and the statusbar:
QMainWindow > QMessageBox { background: white; }
QMainWindow > QStatusBar { background: white; }
QMainWindow > QDialog { background: white; }
--
[ signature omitted ]