QModelIndex MyTreeView
::moveCursor(CursorAction cursorAction, Qt
::KeyboardModifiers modifiers
) {
{
if(index.column() != 2)
return model()->index(index.row(), index.column()+1, index.parent());
setCurrentIndex(model()->index(index.row(), 0, index.parent()));
}
{
if(index.column() != 0)
return model()->index(index.row(), index.column()-1, index.parent());
setCurrentIndex(model()->index(index.row(), 2, index.parent()));
}
return QTreeView::moveCursor(cursorAction, modifiers
);
}
QModelIndex MyTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
{
if(cursorAction == QAbstractItemView::MoveNext)
{
QModelIndex index = currentIndex();
if(index.column() != 2)
return model()->index(index.row(), index.column()+1, index.parent());
setCurrentIndex(model()->index(index.row(), 0, index.parent()));
}
else if(cursorAction == QAbstractItemView::MovePrevious)
{
QModelIndex index = currentIndex();
if(index.column() != 0)
return model()->index(index.row(), index.column()-1, index.parent());
setCurrentIndex(model()->index(index.row(), 2, index.parent()));
}
return QTreeView::moveCursor(cursorAction, modifiers);
}
To copy to clipboard, switch view to plain text mode
Bookmarks