[Interest] Changing QSpinEdit color

A.Dmitrovsky tdiff at yandex.ru
Wed Jun 6 11:07:44 CEST 2012

here i found where is behaviour André is talking about documented:

When a style sheet is active, the QStyle returned by QWidget::style() is a wrapper "style sheet" style, not the platform-specific style. The wrapper style ensures that any active style sheet is respected and otherwise forwards the drawing operations to the underlying, platform-specific style (e.g., QWindowsXPStyle on Windows XP).

06.06.2012, 12:34, "André Somers" <andre at familiesomers.nl>:
> 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é
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

More information about the Interest mailing list