[Interest] Changing QSpinEdit color

André Somers andre at familiesomers.nl
Wed Jun 6 10:34:36 CEST 2012


Op 5-6-2012 20:47, "Alexander Carôt" schreef:
> Hi all,
>
> I have a question in context with QSpinEdit:
>
> On a Mac this call successfully changes the color of the spinEdit:
>
> spin->setAutoFillBackground(true);
> spin->setPalette( *greenFgPalette );
>
> On Win, however, this call seems to be ignored - the spinEdit remains white. Can anyone tell me how to make it work under Win ?
>
> Thanks in advance,
> best
>
> Alex
>
Styles are free to ignore the set palette, and some styles, especially 
those using native rendering like on windows, do in fact ignore the 
palette. However, all styles will obey the style sheet. So, instead of 
the palette, use a style sheet.

spin->setStyleSheet("QSpinBox {background-color: rgb(0, 255, 0);}");

That should work on both platforms.

André




More information about the Interest mailing list