-
-
Save frueter/8a3db7f89868c47d8f6028b024b5c7d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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