[Interest] [QSS] Treeview headache
Clément Geiger
clement.geiger at gmail.com
Mon Sep 30 16:39:43 CEST 2013
Hi there,
I'm stumbling on a very frustrating problem here with QSS.
My problem in a nutshell: I want to add a "highlight on hover" effect on
QAbstractItemView-based classes.
So I wrote that in the app's qss file:
QAbstractItemView::item:hover:!selected {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0
#e7effd, stop: 1 #cbdaf1);
}
So far so good, now my items have a nice blue-ish overlay when the mouse
hovers over them.
Except for the branches in a tree view, which are a separate subcontrol !
So I added that:
QTreeView::branch:hover:!selected {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0
#e7effd, stop: 1 #cbdaf1);
}
Now I have the overlay, but the branches themselves are not drawn
anymore... Shaaame.
Going on, I saw in Qt doc that example of branch customization with images
(second part of
http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtreeview)
, and I thought « great, that's exactly what I need! » It almost worked,
but if some of the branches of the tree have different heights then the
images are scaled and it's ugly. Saaad.
So I tinkered with the border-image property, tried various combinations,
and so far, not so good. I just can't get it right.
If anyone has any thoughts to share about my problems (eg why the original
branches drawing are being wiped out by setting some qss, if there is a
workaround, etc.) I would be more than happy to here them :)
Best,
Clément
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130930/c2043550/attachment.html>
More information about the Interest
mailing list