M
M
Mercury132015-10-26 15:40:12
Qt
Mercury13, 2015-10-26 15:40:12

Qt: how to make the editor in the table behave differently when pressing Tab?

I already asked a question about this: Qt: how to check if a combobox is expanded?
So, the combobox editor in QTableView is set up. But the questions continue. It turned out that the editor behaves funny when you press Tab: it just jumps to another table cell. You should jump to the next component in tab order.
tabKeyNavigation for the table is, of course, disabled. If the cursor is on a non-editable cell (there are some), everything is in order.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2015-12-10
@Mercury13

QModelIndex EditableTable::moveCursor(
        CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
{
    switch (cursorAction) {
    case QAbstractItemView::MoveNext:
    case QAbstractItemView::MovePrevious:
        return QModelIndex();
        break;
    default:
        return Super::moveCursor(cursorAction, modifiers);
    }
}

To push such functionality into Qt Creator, use the "Promote To..." function

K
Konstantin, 2015-10-26
@Drakonn

Then write your own class inherited from QTableView, in the keyboard handler of which you will write everything as you like)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question