Is it possible to highlight a row in a treeview?
I tried doing this by trying to make my own QItemDelegate, but I have absolutely no idea how to do it :s
Is it possible to highlight a row in a treeview?
I tried doing this by trying to make my own QItemDelegate, but I have absolutely no idea how to do it :s
By saying "highlight a row" do you mean that the whole row should be selected (but not a single cell)? If yes, then use
Qt Code:
To copy to clipboard, switch view to plain text mode
Sorry if I misunderstood.
I'm a rebel in the S.D.G.
I'm not sure what you mean either. By default a QTreeView/QTreeWidget will allow you to highlight individual cells. If you want that to go across all cells in a row do the following
Qt Code:
treeview.setAllColumnsShowFocus(True)To copy to clipboard, switch view to plain text mode
Hopefully thats what you're looking for, otherwise you'll need to clarify. Though it doesnt sound like you'll need a delegate, thats for some seriously advanced stuff
Oh no, that's not what I meant, sorry.
What I want to do is to give a background color to a specific row. I'm making a music player and I have a list of songs but I want to make clear which song is currently playing...
Thanks in advance,
Gillis
Hi, if you have a view, you probably also have a model. In Model::data (), use Qt::BackgroundRole and return the color you like.
Ginsengelf
I have tried that before, but it only shows the color when you hover over the row...
You could have a look into the sources of QAbstractItemView::setAlternatingRowColors(). It is not exactly what you want, but maybe it can give you some ideas.
Ginsengelf
Bookmarks