Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED - Sort of] setStyleSheet selection-background-color works perfectly in Windows, but not in Ubuntu linux
Forum Updated to NodeBB v4.3 + New Features

[SOLVED - Sort of] setStyleSheet selection-background-color works perfectly in Windows, but not in Ubuntu linux

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 5.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neveralull
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      suswak
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • T3STYT Offline
        T3STYT Offline
        T3STY
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved