-
-
Save frueter/7d325cfc990703c866dd98807aabc73c 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): | |
def __init__(self, parent=None): | |
super().__init__(parent) | |
self.model = QtGui.QStandardItemModel() | |
self.setModel(self.model) | |
self.__get_data() | |
self.setColumnWidths([30, 30, 100]) | |
preview_w = QtWidgets.QPushButton("What's with the extra column? >>>") | |
self.setPreviewWidget(preview_w) | |
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() | |
w.resize(800, 500) | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment