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,