[SOLVED - Sort of] setStyleSheet selection-background-color works perfectly in Windows, but not in Ubuntu linux
-
I have Qt code that has been working perectly for months under Windows Xp and Windows 7. I installed QtSdk-offline-linux-x86_64-v1.2.1.run on an Ubuntu 11.04 linux machine, and the code works except for some issues with fonts, borders, and colors.
My first problem is that selection-background-color cannot be set.
For example,
@QTableWidget* table = new QTableWidget( ....
table->setStyleSheet("QTableWidget {selection-background-color: blue; selection-color: white}";@
This works fine in Windows, when the user selects a row, the row's background turns blue with the text in white. On the linux machine, the text turns white but the row background turns grey, which is the default behavior if you don't specify selection-background-color.This same problem occurs for QRadioButton which also work perfectly in Windows.
I marked this [Solved - sort of] because I have found that the problem goes away if you set the application style to certain styles, for example:
QApplication::setStyle("windows");I'll do that for this application, but I still think there's a bug here.
-
I have been fighting this thing for some time now. Turns out it works if you setFocusPolicy(Qt::NoFocus) but then again you loose your keyboard control.
also you are setting it to the widget where you could be setting it for QTableWidget::item and QTableWidget::item:selected.
-
If you think this is a bug, and you can make a few tests to prove that to yourself, then you might also consider sending a bug report to the Qt devels. As far as I know Qt uses its own widgets, not the OS provided widgets, so any customization should be working on any platform (unless a platform-specific behavior is implemented in Qt). So your selection color should be working just fine on both Windows and Ubuntu.
You might consider running your application on a different version of Linux (I may suggest Fedora) and see if it bugs the same way as on Ubuntu. You may consider trying your application on a different version of Windows too to avoid any "lucky behaviour" on the only Windows OS you tried it.