DIMEDROLL
5th November 2008, 07:24
I sublcass QTreeView and QStandartItemModel to display some data. The data is displayed as a list with two columns in QTreeView.
QTreeView has such properties in constructor:
// set TreeView properties
setRootIsDecorated(false);
setSelectionBehavior(QAbstractItemView::SelectRows );
setSelectionMode(QAbstractItemView::NoSelection);
setEditTriggers(NoEditTriggers);
setAllColumnsShowFocus(true);
setSortingEnabled(true);
// set header properties
header()->setStretchLastSection(true);
header()->setSortIndicator(0, Qt::AscendingOrder);
header()->setSortIndicatorShown(true);
header()->setClickable(true);
The problem rises when the model updates itself end after that I try to set a current item programmatically. I use setCurrentIndex() to set it. setCurrentIndex() works fine but it doesn't show the focus/cursor (look at attachment picture to understand what I mean). It is the rect around current item.
I pass a QPersistentModelIndex to setCurrentIndex() and check it.
I've debugged setCurrentIndex(). QTreeView::visualRect() fails to set d->pressedPosition because of invalid index. But how can this be possible, the index is checked and is valid?
Do anybody know how to fix that?
QTreeView has such properties in constructor:
// set TreeView properties
setRootIsDecorated(false);
setSelectionBehavior(QAbstractItemView::SelectRows );
setSelectionMode(QAbstractItemView::NoSelection);
setEditTriggers(NoEditTriggers);
setAllColumnsShowFocus(true);
setSortingEnabled(true);
// set header properties
header()->setStretchLastSection(true);
header()->setSortIndicator(0, Qt::AscendingOrder);
header()->setSortIndicatorShown(true);
header()->setClickable(true);
The problem rises when the model updates itself end after that I try to set a current item programmatically. I use setCurrentIndex() to set it. setCurrentIndex() works fine but it doesn't show the focus/cursor (look at attachment picture to understand what I mean). It is the rect around current item.
I pass a QPersistentModelIndex to setCurrentIndex() and check it.
I've debugged setCurrentIndex(). QTreeView::visualRect() fails to set d->pressedPosition because of invalid index. But how can this be possible, the index is checked and is valid?
Do anybody know how to fix that?