PDA

View Full Version : Tab behavior versus Arrow in QTableView



klahey
2nd January 2010, 20:07
Hi,

I have an app that uses a QTableView to display and edit data. It work just as I'd expect every time, except when I change a cell (go into edit mode) and then hit "tab". I expect it to act like it does when I hit up or down arrow after making a change. When I hit "up-arrow" it saves the data and then highlights the cell just above the current one AND the focus remains with the QTableView.

"Tab" is slightly different. It saves the data, highlights the cell to the right and then jumps the focus to the next widget in the tab order. Is there anyway to make it not jump the focus out of the QTableView?

I looked in Qt Designer to see if there was a way to make the tab order jump back to tableView, but no dice. I can't just detect when it loses focus and set it back, because then every time I selected anything else on the screen it would jump back to the tableView (not what I want).

Is there anyway to turn off the "Tab to next widget" abilities of the tableView? I believe I can turn off the "use tab to go to next cell" feature, but that isn't what I want. I want to tab to the next cell if it isn't in edit mode and stay in focus (this works perfectly) - AND I want to be able to type something to change the cell and then hit tab to move to the next cell and stay in focus.

Thanks

RThaden
20th January 2010, 14:58
Hi,

I am not sure, if I understand correctly what you are trying to achieve, but maybe this helps:
Have a look at http://qt.nokia.com/doc/4.6/qabstractitemview.html#EditTrigger-enum

Also, you can try to make your own version of QTableView, overload keyPressedEvent and handle the tab key there.

Best regards,

Rainer