Re: [Interest] Changing QSpinEdit color

2012-06-07 Thread André Somers
Op 7-6-2012 8:45, Till Oliver Knoll schreef:
 Am 06.06.2012 um 13:20 schrieb André Somersan...@familiesomers.nl:

 ... setPalette cannot be relied on, and is thus effectively useless. Pitty 
 is: style sheet support is incomplete (no API for custom widgets), so in 
 some cases (mainly if you use your own widgets), you're basically screwed. 
 You cannot rely on the palette to work properly, but you cannot use style 
 sheets either.
 What exactly do you mean by own widgets? Custom widgets as in You are 
 responsible for painting everything yourself? So why would one ignore the 
 palette colours - in her own drawing code, that is - when there was a need 
 for that in the first place? Or did you mean 3rd party custom widgets?
Both, actually. *I* would not ignore them. The issue is, that if you use 
any of the QStyle API to do the actual rendering (you do want your 
widget to blend in with the platform, don't you?), there is no telling 
if those colors will be used or not. One place where you might run into 
this, for instance, is if you do something as simple as implementing 
your own delegate. And, as you say:
 Anyway, I agree that it is a mess having to deal with two different APIs to 
 reliably set the background colour of some line edit widget (style sheet), 
 which at the same time should have the same background colour as some other 
 custom widget (setPalette()), for instance.
If I style my entire application using a style sheet (mind you: usually 
*one* style sheet, set at the highest possible level), then it is very 
annoying if I have to style my *own* widget low-level using a 
setPallette call on the actual widget.
 I wasn't aware that the style sheet API wasn't available to custom painting 
 code. I guess one could always provide a custom setStyleSheet method, try to 
 parse (a subset of) the CSS yourself and then merge the result with the 
 (subset) CSS result from the parent widget.
The issue with CSS is, is that this cascading thing makes this hard. 
There is no way to get the (subset) CSS result from the parent widget. 
If only there were!
 However IIRC widgets where it is reasonable to set the background colour - 
 QLineEdit where you want to indicate that some input is missing or wrong, for 
 instance - work cross-platform with setPalette.
Can you guarantee that that will work in all (reasonable) styles? Where 
is it documented what widgets do obey the palette, and what widgets 
don't? For what roles? Will it still work in Windows 8, or in the next 
OSX? And isn't a spinbox just as reasonable as a line edit?
 But more often than never people want to also set the colour of some push 
 button or tab switching button. At least on a Mac that is absolutely wacko 
 to do so: people go absolutely banana if they don't see their blue bubbly 
 buttons or most recently their dull gray with decent lighter gray tab 
 highlighting tab buttons! Didn't you know? Colours have basically become 
 outlawed (icons in Finder, anyone?) in the greatest OS X we've ever had - 
 yikes! ;)

 Bottom line: if the native painting code doesn't respect your setPalette 
 calls, then there might be a good reason ;)

I am very much aware of that, and personally I am not a great fan of 
non-native GUI's. But in terms of API, you have to agree that it is a 
bit of a mess that there is no one API that you can rely on for this 
purpose?

Of course, this lack is going to be solved in the Future (TM) by 
introducing the One API To Rule Them All: Quick (Components) ;-)

André

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Changing QSpinEdit color

2012-06-06 Thread A . Dmitrovsky
here i found where is behaviour André is talking about documented:

http://qt-project.org/doc/qt-4.8/stylesheet.html: 
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 an...@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@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Changing QSpinEdit color

2012-06-05 Thread Alexander Carôt
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

-- 
http://www.carot.de
http://www.triologue.de
Email : alexan...@carot.de
Tel.: +49 (0)177 5719797



NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!  

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest