Results 1 to 3 of 3

Thread: Losing palette colors when app goes out of focus.

  1. #1
    Join Date
    Nov 2009
    Posts
    68
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded

    Default Losing palette colors when app goes out of focus.

    I have an app and on certain components I change the palette slightly. I do this by putting this code in the Widget Constructor that contains the component.

    Qt Code:
    1. if (darkTheme) {
    2. QPalette p = ui->strStringEdit->palette( );
    3. p.setColor( QPalette::Active, QPalette::Base, darkPalette.color(QPalette::AlternateBase));
    4. ui->strStringEdit->setPalette( p );
    5. }
    To copy to clipboard, switch view to plain text mode 
    But when the application loses focus (by going to another application) the colors go back to the original colors. When I select my app again the modifications come back.

    How do I freeze the palette?

    Thanks,

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Losing palette colors when app goes out of focus.

    Hi, you probably also need to modify the palette for QPalette::Inactive.

    Ginsengelf

  3. #3
    Join Date
    Nov 2009
    Posts
    68
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded

    Default Re: Losing palette colors when app goes out of focus.

    Thanks! Changed my code to this and it worked!

    Qt Code:
    1. if (darkTheme) {
    2. QPalette p = ui->strStringEdit->palette( );
    3. p.setColor( QPalette::Active, QPalette::Base, darkPalette.color(QPalette::AlternateBase));
    4. p.setColor( QPalette::Inactive, QPalette::Base, darkPalette.color(QPalette::AlternateBase));
    5. ui->strStringEdit->setPalette( p );
    6. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qt + DirectFB == Windows Losing Focus
    By Brandybuck in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 15th October 2014, 21:37
  2. Replies: 2
    Last Post: 4th June 2014, 10:20
  3. Replies: 1
    Last Post: 19th March 2014, 23:25
  4. Using StyleSheet Without Losing 3D Effects
    By metdos in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2009, 11:20
  5. QGLWidget window redrawing contents when losing focus
    By Barry79 in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2009, 14:37

Tags for this Thread

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.