View Full Version : Style Sheet Settings between WindowsXP, Vista, Windows7

15th March 2011, 19:18
We have an application that will run on either WindowsXP or Windows 7.
Some of the controls on this app can have their Selected Item colors modified by the User. We use the 'setStyleSheet' function and pass in a string such as:

myWidget->setStyleSheet("selection-background-color: rgb(0,0,128); selection-color: rgb(255,255,255);");

In WindowsXP Pro, this works great every time. However, when the application is executed in Windows 7, certain controls such as QTreeWidget will not change the selected item background color. I tested this in Qt Designer on a Windows 7 machine by changing the styleSheet property using the Edit Style Sheet Dialog and this didn't change the Selected Item colors for the QTreeWidgets either.

So far, the only solution I seem to have found is to call the static function "QApplication::setStyle("WindowsXP")" just before my QApplication variable is constructed in my main.cpp file. The only down-side is that the application does look more like a WinXP app when executed in Windows 7.

We tried all the style sheet settings/configurations to make this work right and could not get anything other than calling the static function "QApplication::setStyle" to make the colors change correctly for all widgets.

Has anyone else had this problem in Qt and if so, what were your solutions? Or, is this the best solution?