Greetings,

I want to be able to change the color of the statusBar message that appears in my QMainWindow object based upon the type of message; normal, warning, error...

The problem I need help with is that I'm also using the timer function of the statusBar. This means that if I change the palette of the statusBar and display the message, I must wait until the timer elapses to change the palette back.

For example, I display a warning message (forces a palette change to blue). If, after I show the message, I change the palette back, the palette switching happens so fast that the string never appears in the warning color.

Qt Code:
  1. void MainWin::DisplayStatus( QString sStatus, QColor rgbColor, int duration )
  2. {
  3. if ( !sStatus.isEmpty() )
  4. {
  5. QPalette palette;
  6. palette.setColor( QPalette::WindowText, rgbColor );
  7. statusBar()->setPalette( palette );
  8. statusBar()->showMessage( sStatus, duration );
  9.  
  10. // resets the palette before the message can be seen in the previous color
  11. if ( rgbColor != COLOR_StatusNorm )
  12. {
  13. palette.setColor( QPalette::WindowText, COLOR_StatusNorm );
  14. statusBar()->setPalette( palette );
  15. }
  16. }
  17. }
To copy to clipboard, switch view to plain text mode 

If I don't reset the statusBar palette, all subsequent messages will use the warning color.

Most of the messages have a duration of 3-5 seconds so a Sleep() is not appropriate.

Does anyone have suggestions or am I trying to do something the statusBar was not intended for?