Results 1 to 10 of 10

Thread: Changing QPalette Highlight doesn't work on Windows 7

  1. #1
    Join Date
    Mar 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing QPalette Highlight doesn't work on Windows 7

    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 :
    Qt Code:
    1. QPalette p = myListWidget->palette();
    2. if( myListWidget->currentItem()->background().color() == Qt::green )
    3. {
    4. p.setColor(QPalette::Highlight, Qt::green);
    5. }
    6. else
    7. {
    8. p.setColor(QPalette::Highlight, Qt::red);
    9. }
    10. myListWidget->setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    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 ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Ok, thanks for the tip, I'll try that ASAP

  4. #4
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Quote Originally Posted by wysota View Post
    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

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Qt follows the OS guidelines. If Win7 guidelines dictate the color can't be changed, QPalette will not affect it, only stylesheets will.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    Dong Back Kim (6th August 2011)

  7. #6
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Quote Originally Posted by wysota View Post
    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

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Quote Originally Posted by Dong Back Kim View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #8
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Quote Originally Posted by wysota View Post
    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,
    Dong Back Kim

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Quote Originally Posted by Dong Back Kim View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    Dong Back Kim (7th August 2011)

  12. #10
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing QPalette Highlight doesn't work on Windows 7

    Quote Originally Posted by wysota View Post
    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. =)
    Dong Back Kim

Similar Threads

  1. Replies: 0
    Last Post: 4th March 2011, 19:18
  2. Qt Creator SDK 2010.05 - 'Hallo world' doesn't work on Windows 7 64bit
    By mastupristi in forum Qt Tools
    Replies: 1
    Last Post: 15th November 2010, 09:25
  3. Replies: 2
    Last Post: 29th June 2010, 00:40
  4. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 07:27
  5. Connection doesn't work
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2007, 12:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.