Hi
I'm trying to use a stylesheet on QListView and almost got it working except for a couple of things which I can't get to work.
Here is the style sheet that works:
// Hover effect:
stylesheet += "QListView::item:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FAFBFE, stop: 1 #DCDEF1) }";
// Selected item gradient:
stylesheet += "QListView::item:selected:active { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6a6ea9, stop: 1 #888dd9); }";
// The padding of items in the list:
stylesheet += "QListView::item { padding: 5px 1px 5px 1px;}";
d->verticalModeList->setStyleSheet(stylesheet);
QString stylesheet = "";
// Hover effect:
stylesheet += "QListView::item:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FAFBFE, stop: 1 #DCDEF1) }";
// Selected item gradient:
stylesheet += "QListView::item:selected:active { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6a6ea9, stop: 1 #888dd9); }";
// The padding of items in the list:
stylesheet += "QListView::item { padding: 5px 1px 5px 1px;}";
d->verticalModeList->setStyleSheet(stylesheet);
To copy to clipboard, switch view to plain text mode
The two things I don't get:
1) Setting the background of the view does not work. When I add the following the background changes but all the other effects (hover etc.) breaks and does not work anymore. I set the background like this:
stylesheet += "background-color: #EEEEEE;";
stylesheet += "background-color: #EEEEEE;";
To copy to clipboard, switch view to plain text mode
2) I want to get rid of the border around the text of the selected item in the list view. I've attempted to find this border by making it yellow and once I find it I will remove it, however the following creates a yellow border around the whole item.
// The text underneath the selected item:
stylesheet += "QListView::item::text { border-style: dot-dash; border-width: 5px 1px 5px 1px; border-color: yellow; }";
// The text underneath the selected item:
stylesheet += "QListView::item::text { border-style: dot-dash; border-width: 5px 1px 5px 1px; border-color: yellow; }";
To copy to clipboard, switch view to plain text mode
Sorry for not posting pictures but don't have a place to host them.
Cheers,
Jaco
Added after 1 3 minutes:
Just to clarify, d->verticalModeList is a QListWidget in my previous post.
Bookmarks