Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, October 2007
vista problem


Message 1 in thread

Hi,
i have implemented this method for my class QPushButtonScansion

void QPushButtonScansion::focusInEvent ( QFocusEvent * event )
{
	setPalette(scansionPalette);
}


then, the my pushButtonScansion don't change color if my application run on 
windows vista. On linux and windows xp, my method run correctly.
Suggestions?
                                Nicola

--
 [ signature omitted ] 

Message 2 in thread

Nicola De Filippo schrieb:
> [...]
> void QPushButtonScansion::focusInEvent ( QFocusEvent * event )
> {
> 	setPalette(scansionPalette);
> }
> 
> then, the my pushButtonScansion don't change color if my application run on 
> windows vista. On linux and windows xp, my method run correctly. [...]

I bet it does not work on XP either when you use XP style rather than 
classic style ...

This is due to WindowsXP and Vista using the native style engine which 
does not allow button color changes. You might use a different style for 
the button, as by calling

     setStyle ("Windows");

in the button's constructor. Note however, that there might be more 
elegant/portable ways to solve this ...

Best Regards / Mit freundlichen Grüßen
Rainer Wiesenfarth

-- 
 [ signature omitted ] 

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Message 3 in thread

On 10/26/07, Rainer Wiesenfarth <Rainer.Wiesenfarth@xxxxxxxx> wrote:
> Nicola De Filippo schrieb:
> > [...]
> > void QPushButtonScansion::focusInEvent ( QFocusEvent * event )
> > {
> >       setPalette(scansionPalette);
> > }
> >
> > then, the my pushButtonScansion don't change color if my application run on
> > windows vista. On linux and windows xp, my method run correctly. [...]
>
> I bet it does not work on XP either when you use XP style rather than
> classic style ...
>
> This is due to WindowsXP and Vista using the native style engine which
> does not allow button color changes. You might use a different style for
> the button, as by calling

OS X is the same way - all buttons are drawn in the system color (blue
or graphite - user configurable) regardless of the Qt palette
settings.
-- 
 [ signature omitted ] 

Message 4 in thread

Rainer Wiesenfarth schrub:
> Nicola De Filippo schrieb:
> > ...
> This is due to WindowsXP and Vista using the native style engine which 
> does not allow button color changes. You might use a different style for 
> the button, as by calling
> 
>     setStyle ("Windows");
> 
> in the button's constructor. Note however, that there might be more 
> elegant/portable ways to solve this ...

Indeed: and the portable way comes from Qt itself in the form of CSS: I 
haven't used it much myself, so the following syntax might be plain wrong:

   QButton myButton->setStyleSheet("background-color: red;");

Works (should) on any platform and with any style, as I have been told :)

Cheers, Oliver

--
 [ signature omitted ] 

Message 5 in thread

Till Oliver Knoll schrub:
> ...
>   QButton myButton->setStyleSheet("background-color: red;");
                    ^^^^

To self: Okay okay, so I need my week-end right now! ;)

Have a nice week-end everyone!
   Cheers, Oliver


--
 [ signature omitted ] 

Message 6 in thread

On 10/26/07, Till Oliver Knoll <oliver.knoll@xxxxxxxxxxx> wrote:
> Rainer Wiesenfarth schrub:
> > Nicola De Filippo schrieb:
> > > ...
> > This is due to WindowsXP and Vista using the native style engine which
> > does not allow button color changes. You might use a different style for
> > the button, as by calling
> >
> >     setStyle ("Windows");
> >
> > in the button's constructor. Note however, that there might be more
> > elegant/portable ways to solve this ...
>
> Indeed: and the portable way comes from Qt itself in the form of CSS: I
> haven't used it much myself, so the following syntax might be plain wrong:
>
>    QButton myButton->setStyleSheet("background-color: red;");
>
> Works (should) on any platform and with any style, as I have been told :)

But only for QStyles that pay attention to color settings. As I
mentioned earlier, OS X Aqua buttons are always blue (or graphite
gray) regardless of the application's palette and style sheet
settings. Vista could be the same way, but I haven't had a chance to
test this yet.

-- 
 [ signature omitted ] 

Message 7 in thread

Andrew Medico schrub:
> > ...
> But only for QStyles that pay attention to color settings. As I
> mentioned earlier, OS X Aqua buttons are always blue (or graphite
> gray) regardless of the application's palette and style sheet
> settings. Vista could be the same way, but I haven't had a chance to
> test this yet.

That's not what I've been told by a member from Trolltech on this list; 
and your statement would contradict the Qt documentation (or you have 
discovered a bug):

"If you set the background color of a QPushButton to be red, you can be 
assured that the button will have a red background in all styles, on all 
platforms." (http://doc.trolltech.com/4.3/stylesheet.html#overview)

Off course since I don't have neither OS X nor Vista I didn't have the 
chance to test this ;)

Cheers< oliver

--
 [ signature omitted ] 

Message 8 in thread

On 10/31/07, Till Oliver Knoll <oliver.knoll@xxxxxxxxxxx> wrote:
> Andrew Medico schrub:
> > > ...
> > But only for QStyles that pay attention to color settings. As I
> > mentioned earlier, OS X Aqua buttons are always blue (or graphite
> > gray) regardless of the application's palette and style sheet
> > settings. Vista could be the same way, but I haven't had a chance to
> > test this yet.
>
> That's not what I've been told by a member from Trolltech on this list;
> and your statement would contradict the Qt documentation (or you have
> discovered a bug):
>
> "If you set the background color of a QPushButton to be red, you can be
> assured that the button will have a red background in all styles, on all
> platforms." (http://doc.trolltech.com/4.3/stylesheet.html#overview)
>
> Off course since I don't have neither OS X nor Vista I didn't have the
> chance to test this ;)

I've tried it. Aqua buttons remail gray/blue regardless of Qt
palette/stylesheet settings. I'll file a bug report about it.

-- 
 [ signature omitted ] 

Message 9 in thread

On 10/31/07, Andrew Medico <a.medico@xxxxxxxxx> wrote:
> On 10/31/07, Till Oliver Knoll <oliver.knoll@xxxxxxxxxxx> wrote:
> > Andrew Medico schrub:
> > > > ...
> > > But only for QStyles that pay attention to color settings. As I
> > > mentioned earlier, OS X Aqua buttons are always blue (or graphite
> > > gray) regardless of the application's palette and style sheet
> > > settings. Vista could be the same way, but I haven't had a chance to
> > > test this yet.
> >
> > That's not what I've been told by a member from Trolltech on this list;
> > and your statement would contradict the Qt documentation (or you have
> > discovered a bug):
> >
> > "If you set the background color of a QPushButton to be red, you can be
> > assured that the button will have a red background in all styles, on all
> > platforms." (http://doc.trolltech.com/4.3/stylesheet.html#overview)
> >
> > Off course since I don't have neither OS X nor Vista I didn't have the
> > chance to test this ;)
>
> I've tried it. Aqua buttons remail gray/blue regardless of Qt
> palette/stylesheet settings. I'll file a bug report about it.

Trolltech support reminded me of this section, at the bottom of that page:

"Warning: Qt style sheets are currently not supported for QMacStyle
(the default style on Mac OS X) and custom QStyle subclasses. We plan
to address this in some future release."

So the documentation is a bit confusing (making one statement, then
adding an exception several paragraphs later), but not actually
incorrect.

-- 
 [ signature omitted ]