maranos
29th April 2014, 15:44
Hi,
when the user presses TAB while editing an item in a QTreeView, the view closes the current editor and starts editing the item below. Is there a way to change this behavior so that the item on the right is edited? (similar to LibreOffice Calc and probably Excel)
I tried setting event filters and overwriting the event-function in the tree, the viewport and the editor (using a custom delegate), but I was not able to intercept this TAB event.
Below you will find a simple test script (in PyQt), without event filters.
Thanks
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import Qt
#from PyQt4 import QtCore, QtGui as QtWidgets
#from PyQt4.QtCore import Qt
class TreeView(QtWidgets.QTreeWidget):
def __init__(self):
super().__init__()
self.setColumnCount(5)
for i in range(3):
item = QtWidgets.QTreeWidgetItem(["Some", "Test", "Strings"])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled)
self.addTopLevelItem(item)
app = QtWidgets.QApplication([])
tree = TreeView()
tree.show()
app.exec_()
when the user presses TAB while editing an item in a QTreeView, the view closes the current editor and starts editing the item below. Is there a way to change this behavior so that the item on the right is edited? (similar to LibreOffice Calc and probably Excel)
I tried setting event filters and overwriting the event-function in the tree, the viewport and the editor (using a custom delegate), but I was not able to intercept this TAB event.
Below you will find a simple test script (in PyQt), without event filters.
Thanks
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import Qt
#from PyQt4 import QtCore, QtGui as QtWidgets
#from PyQt4.QtCore import Qt
class TreeView(QtWidgets.QTreeWidget):
def __init__(self):
super().__init__()
self.setColumnCount(5)
for i in range(3):
item = QtWidgets.QTreeWidgetItem(["Some", "Test", "Strings"])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled)
self.addTopLevelItem(item)
app = QtWidgets.QApplication([])
tree = TreeView()
tree.show()
app.exec_()