QWidget setStyleSheet and text color
I try to get working veerey simple thing:
I have class "MyTabButton : public QPushButton" and want to draw by myself with MyTabButton::paintEvent.
I also setStyleSheet with normal & checked style:
border: 1px solid #acacac;
background-position: top center;
text-align: bottom center;
But got painful problem: inside paintEvent I can't get color for checked state to draw text with:
@style()->drawItemText(&p, lrect, Qt::AlignCenter | Qt::AlignBottom, opt.palette, true, text(), QPalette::Text);@
I check source code - Qt use QRenderRule to draw, but this is internal class.
How can I get colors from stylesheet in paintEvent ? Or hack somehow ?
[edit: added missing coding tags @ SGaist]
Style sheet and palettes are two independent beasts. However you could try to integrate the palette in the style sheet like described "here":http://doc.qt.io/qt-5/stylesheet-reference.html#paletterole
Hope it helps
Thank you, didn't see.
At least will be easier to synchronise stylesheet colors & native style colors.