PDA

View Full Version : Changing QPalette Highlight doesn't work on Windows 7



BinbinDesbois
16th March 2011, 10:11
Hi

I'm using Qt since 3 years and my current project is running both on Windows XP and 7.

Here's the code that cause the problem :


QPalette p = myListWidget->palette();
if( myListWidget->currentItem()->background().color() == Qt::green )
{
p.setColor(QPalette::Highlight, Qt::green);
}
else
{
p.setColor(QPalette::Highlight, Qt::red);
}
myListWidget->setPalette(p);


One item can have it's background green colored. When I select an item, I want the selection to be red colored, or green if it's background is green.

It perfectly work on XP. On Seven, the background tip is working, not the Highlight which remains default colored. I've debugged both executables and get exactly the same values in Qt code.

Any clue ?

wysota
16th March 2011, 10:25
It is possible that Windows 7 forces a default highlight color. You can probably override it by providing your own item delegate where you do the coloring yourself.

BinbinDesbois
16th March 2011, 14:47
Ok, thanks for the tip, I'll try that ASAP

Dong Back Kim
5th August 2011, 03:51
It is possible that Windows 7 forces a default highlight color. You can probably override it by providing your own item delegate where you do the coloring yourself.

Same here. QPalette doesn't seem to work properly on Windows 7. No matter what color combinations I use it will be ignored somehow. Shouldn't this be handled by Qt internals rather than manual overriding?

Regards,
Dong Back Kim

wysota
6th August 2011, 01:11
Qt follows the OS guidelines. If Win7 guidelines dictate the color can't be changed, QPalette will not affect it, only stylesheets will.

Dong Back Kim
6th August 2011, 10:17
Qt follows the OS guidelines. If Win7 guidelines dictate the color can't be changed, QPalette will not affect it, only stylesheets will.

I see. Thanks for the information. I was thinking that if Qt follows the OS preference, then in terms of user experience and interactions, the same application produces different results depended on base OS and that sort of breaks the portability of the applications. However, as you mentioned if using stylesheets provides the common theme then it is no big deal.

Regards,
Dong Back Kim

wysota
6th August 2011, 11:07
I was thinking that if Qt follows the OS preference, then in terms of user experience and interactions, the same application produces different results depended on base OS and that sort of breaks the portability of the applications.
It depends how you define "portability". To me the application itself should be platform-agnostic in a way that the functionality remains the same and the application blends well into the system. The fact that I work on Mac and you work on Symbian shouldn't force me to buy a touch screen or control the application through soft buttons, should it?

Dong Back Kim
6th August 2011, 15:01
It depends how you define "portability". To me the application itself should be platform-agnostic in a way that the functionality remains the same and the application blends well into the system. The fact that I work on Mac and you work on Symbian shouldn't force me to buy a touch screen or control the application through soft buttons, should it?

For your example, I can't agree more. However, when it comes to visual information such as color or layout, shouldn't it be somewhat consistent as much as possible even it's different platform? For example, if item text color in a QListView means somwhat very important then I believe it should be preserved even the base OS is different. Since you mentioned "russian-chinese language barrier issue", I want to paraphrase the example. Both Russian and Chinese use "Red" as "stop" and "Green" as "go-ahead" in their traffic networks. =)

Regards,

wysota
7th August 2011, 11:28
However, when it comes to visual information such as color or layout, shouldn't it be somewhat consistent as much as possible even it's different platform?
No, I don't think so. If your program requires such things then I'd call it a misdesign.


For example, if item text color in a QListView means somwhat very important then I believe it should be preserved even the base OS is different. Since you mentioned "russian-chinese language barrier issue", I want to paraphrase the example. Both Russian and Chinese use "Red" as "stop" and "Green" as "go-ahead" in their traffic networks. =)

Suppose you want a red push-button to mark some important button in your program. What if the user of your program has such a theme installed in his system that all push buttons are by default red? If the OS guidelines state that the button colour is defined by the theme, relying on artificial colour settings is a misdesign and you should find a different highlighting mechanism (for example by rearranging widgets on the form so that the button is more exposed).

This is a common mistake to assume that if my desktop looks in some way, everybody's desktops look similar. And the second common problem is that people think that if they use a program in a specific way, everybody uses (or will want to use or just have to use because it's superior to their current habits) this program the same way too. It's quite egocentric to assume that, isn't it?

Dong Back Kim
7th August 2011, 12:19
No, I don't think so. If your program requires such things then I'd call it a misdesign.



Suppose you want a red push-button to mark some important button in your program. What if the user of your program has such a theme installed in his system that all push buttons are by default red? If the OS guidelines state that the button colour is defined by the theme, relying on artificial colour settings is a misdesign and you should find a different highlighting mechanism (for example by rearranging widgets on the form so that the button is more exposed).

This is a common mistake to assume that if my desktop looks in some way, everybody's desktops look similar. And the second common problem is that people think that if they use a program in a specific way, everybody uses (or will want to use or just have to use because it's superior to their current habits) this program the same way too. It's quite egocentric to assume that, isn't it?

Quite right. =)