[Qt-interest] Backgrounds and style sheets problem
Wagner Sales
wsales at gmail.com
Fri May 22 01:47:20 CEST 2009
Hi all,
I'm setting a background in a customized widget by using style sheets.
After some troubles, I found this code that's make my widgets works
fine (paint event reimplement):
void paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
The problem now are that's I put a widget with some buttons in this
widget, and all the buttons have the following style sheet:
QToolButton { /* all types of tool button */
min-width: 64px;
min-height: 64px;
border-style: outset;
border-width: 1px;
border-radius: 3px;
border-color: gray;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #c4c5c6, stop: 0.5
#1e1e1e, stop:1 #666868);
}
QToolButton:pressed{
border-color: #2b54a0;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #b2cadb, stop: 0.5 #2b54a0, stop:1 #008df0);
}
QToolButton:checked {
border-color: #2b54a0;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #b2cadb, stop: 0.5 #2b54a0,
stop:1 #008df0);
}
Well, If I remove the background from the grand parent widget, the
parent widget assumes the background color from the grand parent and
the child buttons have the correct appearance ( gradients, colors, etc
). But if I put the background, the style simply not works completely!
For example, the min-width, min-height and other options works, but
background-color don't works and my buttons have the same background
image from my grand parent widget. I tried to put the style in the
widget, in the buttons, but not works. Someone can helps please?
Regards,
Wagner Sales
More information about the Qt-interest-old
mailing list