Anybody knows how to make selected cell in a row look like this with StyleSheets ? I'm been trying but no success...
I'm using QTreeViews, with row selection. A very thin dotted line appears by default, but I want a more evident rectangle.
Anybody knows how to make selected cell in a row look like this with StyleSheets ? I'm been trying but no success...
I'm using QTreeViews, with row selection. A very thin dotted line appears by default, but I want a more evident rectangle.
Last edited by jpujolf; 2nd March 2009 at 13:16. Reason: mistake
try:
Qt Code:
{ background-color:transparent; color:blue; }To copy to clipboard, switch view to plain text mode
Thanks, but doesn't work.
ALL cells on the row are in blue, because selection is QAbstractItemView::SelectRows.
I only want the one is selected and focused ( Qt paints a thin dotted line around it ).
that is possible in QTableView
I haven't tested it, but if you make this call :
Qt Code:
To copy to clipboard, switch view to plain text mode
Is still working ? Anyway, I'm forced to use QTreeView, cannot use QTableView. As I show in the capture screen, my data has a tree structure.
Hi, Will delegates suit you ?
you can try the following -
Just set it on your treeview / tree widget.Qt Code:
{ public: { { painter->save(); pen.setWidth(2); painter->setPen(pen); painter->drawRect(option.rect.adjusted(1,1,-1,-1)); painter->restore(); } } };To copy to clipboard, switch view to plain text mode
It works ,, I tested it..
May be you can try with style sheet too... try focus instead of selected.
Last edited by aamer4yu; 2nd March 2009 at 17:43.
jpujolf (3rd March 2009)
As usual, I've made a KISS ( Keep It Simple Stupid ), so setting this in the styleSheet works like a charm !!
Qt Code:
{ background-color:transparent; color:blue; }To copy to clipboard, switch view to plain text mode
Thanks a lot !!
jpujolf, how did you make root elements to draw different background?
I've done it by overloading QVariant QAbstractItemModel::data ( const QModelIndex & Index, int Role ) const
with role Qt::BackgroundRole. Not all can be done with stylesheets...
Bookmarks