Tomáš Zato
Tomáš Zato

Reputation: 53338

Prevent selected items in unfocused table widget from becoming gray

When I select items in QTableWidget, it looks like this:

enter image description here

But when I focus other widget, it looks like this:

enter image description here

I want the items to remain blue as long as they're selected. I tried to enforce it using QSS (CSS):

QListWidget::item:selected:active, QListWidget::item:selected:!active {
    background: blue;
}

QListWidget::item:selected {
    background: blue;
}

Didn't help. What can I do to prevent selected items from becoming gray?

Upvotes: 3

Views: 958

Answers (1)

Tomáš Zato
Tomáš Zato

Reputation: 53338

Turns out that background: is not the correct property to change selection background. This is correct:

QTableView::item:selected:!active
{
       /*selection-background-color: #3399ff;*/
    selection-background-color: #93CAFF;
    /** doesnt work **/
    color: white;
}

The text color setting still doesn't work, but it's better than nothing.

enter image description here

Upvotes: 1

Related Questions