Hi!

Here is what i need: Display an icon in the first column of QTreeView. Icon should remain at 1st column even if the column is dragged to some other position.


Here is what i did: Inherited from QAbstractItemDelegate to create a GItemDelegate whose paint method has something like this
Qt Code:
  1. QTreeView *t_view = qobject_cast<QTreeView*>(parent());
  2. if(t_view)
  3. if(t_view->header()->visualIndex(index.column()) == 0){
  4. value = model->data(index, Qt::DecorationRole);
  5. pixmap = decoration(opt, value);
  6. pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0):QRect(QPoint(0, 0), option.decorationSize));
  7. }
To copy to clipboard, switch view to plain text mode 

New problem: Documentation for header()->visualIndex say that
Hidden sections still have valid visual indexes
Hence, if first column is hidden icon is not visible.
-----------------------------------------------------------
So the question is how to (quickly) determine the first visible column of QTreeView in GItemDelegate.

Thanks