From b0aa4621fb206c877046b50253cdf6302f1c1513 Mon Sep 17 00:00:00 2001 From: Ivan Holmes Date: Fri, 1 Nov 2019 20:28:28 +0000 Subject: [PATCH] sort out column resizing by user and program --- chordsheet/tableView.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/chordsheet/tableView.py b/chordsheet/tableView.py index 0d4a7f3..4144299 100644 --- a/chordsheet/tableView.py +++ b/chordsheet/tableView.py @@ -30,9 +30,14 @@ class MTableView(QtWidgets.QTableView): def __init__(self, parent): super().__init__(parent) + self.model = MItemModel() + self.setModel(self.model) + self.verticalHeader().hide() self.horizontalHeader().show() - self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch) + self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Interactive) + self.horizontalHeader().setStretchLastSection(True) + self.setShowGrid(False) #self.setDragDropMode(self.InternalMove) #self.setDragDropOverwriteMode(False) @@ -40,9 +45,6 @@ class MTableView(QtWidgets.QTableView): # Set our custom style - this draws the drop indicator across the whole row self.setStyle(MProxyStyle()) - self.model = MItemModel() - self.setModel(self.model) - class ChordTableView(MTableView): def __init__(self, parent): @@ -60,6 +62,8 @@ class ChordTableView(MTableView): self.model.appendRow(rowList) + self.resizeColumnsToContents() + class BlockTableView(MTableView): def __init__(self, parent): @@ -75,4 +79,6 @@ class BlockTableView(MTableView): item.setEditable(False) item.setDropEnabled(False) - self.model.appendRow(rowList) \ No newline at end of file + self.model.appendRow(rowList) + + self.resizeColumnsToContents() \ No newline at end of file