PDA

View Full Version : System border color



folibis
22nd October 2013, 06:54
Now I work on custom widget and I want to draw some element on it. Shortly, it looks like button.
But I don't wont to use hardcoded color instead I want to draw it with system colors.
I looked in documentation but did'nt found it.
So how can I get system palette, or rather border color, like border color of QLineEdit?

spirit
22nd October 2013, 08:18
For obtaining "system" palette use QApplication::palette. Also, take a look at QStyle, because this one is responsible for rendering widgets.

folibis
22nd October 2013, 11:00
Yes, I know about QApplication::palette and also about QStyle. But i dind'nt found a way to obtain system color for borders

spirit
22nd October 2013, 11:14
Did you check how a button is rendered in QStyle?
I guess you need QPalette::shadow.
See, QWindowsStyle


...
case PE_FrameDefaultButton: {
QPen oldPen = p->pen();
p->setPen(opt->palette.shadow().color());
QRect rect = opt->rect;
rect.adjust(0, 0, -1, -1);
p->drawRect(rect);
p->setPen(oldPen);
break;
}
...
.