PDA

View Full Version : QListView StyleSheet NOT WORKING!



QbelcorT
19th March 2009, 01:13
hi, ok it seems Trolltech wants me to become a rocket scientist, I can't figure out why this stylesheet will not work. The only part of it working is show-decoration-selected: 1;
This is the example right out of the docs, I want to make it work before I put my style in. ( change font, and color).
I have QtEmbedded 4.4.1
Thanks for any tips.



ui->listWidget->setStyleSheet("QListView { show-decoration-selected: 1;}\
item:alternate { background: #EEEEEE;}\
item:selected:active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ADAFE5, stop: #8588B2);}\
item:selected:!active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #6a6ea9, stop: #888dd9);}");

JimDaniel
19th March 2009, 03:25
Nice-looking GUI.

I looked through some old code where I styled a QListWidget and my code looked similar to yours except that I called the items with class scope (i.e. QListWidget::item:alternate), so maybe it's that. I've never worked with Qt embedded though.

wysota
19th March 2009, 09:19
Do you use a custom delegate? If so, what did you derive it from?

QbelcorT
19th March 2009, 13:34
Hi.
No I am not using a custom delegate. For the list items I am using the text name and an icon with it. Created it using the designer. All I would like to do is change the font to bold when the item is selected.

Lykurg
19th March 2009, 13:42
Hi, the qlineargradient () syntax is wrong. You have forgotten a number for the last stop.

QbelcorT
22nd March 2009, 08:38
my bad, thanks Lykurg, I forgot the last stops. I think I'll leave the selection color in for the rectangle, it looks better than bolding the text.



#define LISTVIEWSTYLE "QListView { show-decoration-selected: 1;}\
QListView::item:alternate { background: transparent;}\
QListView::item:selected:active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ADAFE5, stop: 1 #8588B2);}\
QListView::item:selected:!active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #6a6ea9, stop: 1 #888dd9);}"