[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Re: Tab key navigation in QtableView
From:       Nicolas Girard <nicolas.girard () nerim ! net>
Date:       2007-09-25 22:39:15
Message-ID: 200709260039.15907.nicolas.girard () nerim ! net
[Download RAW message or body]

On Tue, 15 May 2007 11:55:35 +0100, joanne matthews (RRes-Roth) wrote:
> Can anyone explain why in the PyQt example queryModel.pyw, pressing tab
> after editing a cell in the qtableview displayed by EditableSqlModel,
> the current index is set to 0,0? I'd like to use the example for
> something similar but after editing a cell and pressing tab, I'd like
> the cursor to go to the next cell.

I could find a solution to this, after having a look into the Qt sources.

In editing mode, pressing tab makes QAbstractItemView.closeEditor() call
QAbstractItemView.moveCursor(MoveNext, Qt::NoModifier).

With this in mind, we can reimplement QAbstractItemView.moveCursor such as:

    def moveCursor (self, cursorAction, modifiers ):
        if cursorAction==QtGui.QAbstractItemView.MoveNext 
            and modifiers==QtCore.Qt.NoModifier:
            ix=self.currentIndex()
            (col, row, parent)=(ix.column(), ix.row(), ix.parent())
            if col < self.model().columnCount(parent)-2:
                return self.model().index(row, col+1, parent)
        return QtGui.QTreeView.moveCursor(self, cursorAction,  modifiers)

Hope that helps,
Cheers,
Nicolas
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic