Skip to content

Instantly share code, notes, and snippets.

@frueter
Created September 20, 2022 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frueter/8a3db7f89868c47d8f6028b024b5c7d6 to your computer and use it in GitHub Desktop.
Save frueter/8a3db7f89868c47d8f6028b024b5c7d6 to your computer and use it in GitHub Desktop.
from PySide2 import QtWidgets, QtGui, QtCore
class ColumnView(QtWidgets.QColumnView):
"""Column view to choos show, sequence, shot"""
def __init__(self, parent=None):
super().__init__(parent)
self.model = QtGui.QStandardItemModel()
self.setModel(self.model)
self.__get_data()
self.setColumnWidths([30, 30, 100])
self.installEventFilter(self)
def eventFilter(self, widget, event):
if event.type() == QtCore.QEvent.ShortcutOverride and event.key() == QtCore.Qt.Key_Tab:
selection = self.selectionModel()
target_index = selection.currentIndex().child(0, 0)
print(self.model.data(target_index))
selection.select(target_index, QtCore.QItemSelectionModel.ClearAndSelect)
return True
return False
def __get_data(self):
for i in ["a", "b", "c"]:
item = QtGui.QStandardItem(str(i))
self.model.appendRow(item)
for ii in ["d", "e", "f"]:
item2 = QtGui.QStandardItem(str(ii))
item.appendRow(item2)
for iii in ["g", "h", "i"]:
item3 = QtGui.QStandardItem(str(iii))
item2.appendRow(item3)
if __name__ == '__main__':
import sys
args = sys.argv
app = QtWidgets.QApplication(args)
w = ColumnView()
w.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment