PDA

View Full Version : QTreewidget stylesheet problem: second column



trallallero
13th October 2011, 09:13
I'm facing a problem using stylesheets with QTreeWidget.

I'm working with Qt 4.7 and these are the stylesheets I'm using, got from:
http://doc.qt.nokia.com/4.8/stylesheet-examples.html


QTreeView {
show-decoration-selected: 1;
}

QTreeView::item {
border: 1px solid #d9d9d9;
border-top-color: transparent;
border-bottom-color: transparent;
}

QTreeView::item:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
border: 1px solid #bfcde4;
}

QTreeView::item:selected {
border: 1px solid #567dbc;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
}

QTreeView::item:selected:active{
border: 1px solid yellow;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
}

QTreeView::item:selected:!active {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
}


Everything works fine if I select an item in column 1, but when I click an item in column 2, it's not blue highlighted.
The only thing you can see are the dots around the item.

Why ?

trallallero
13th October 2011, 12:11
Ok, solved.

item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);

trallallero
24th November 2011, 12:11
I have another problem: when I enable a plugin, it calls:

treeWidget->setItemDelegate(itemDelegate);
and, doing this, the stylesheets of the QTreewidget are lost.

I've tried to set them again after the plugin has been enabled, but it doesn't work.
Is it normal ? can I solve the problem ?