Fixed listTreeView.header auto-resize on Qt.py

This commit is contained in:
alby128 2017-10-08 16:05:08 +02:00
parent 850a2d6783
commit 4dff204747
1 changed files with 14 additions and 5 deletions

View File

@ -658,6 +658,12 @@ class MainWindow(QtWidgets.QMainWindow):
self.listTreeView.setFirstColumnSpanned(roomtocheck, self.listTreeView.rootIndex(), True) self.listTreeView.setFirstColumnSpanned(roomtocheck, self.listTreeView.rootIndex(), True)
roomtocheck += 1 roomtocheck += 1
self.listTreeView.header().setStretchLastSection(False) self.listTreeView.header().setStretchLastSection(False)
if IsPySide2:
self.listTreeView.header().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
self.listTreeView.header().setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
self.listTreeView.header().setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
self.listTreeView.header().setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents)
if IsPySide:
self.listTreeView.header().setResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) self.listTreeView.header().setResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
self.listTreeView.header().setResizeMode(1, QtWidgets.QHeaderView.ResizeToContents) self.listTreeView.header().setResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
self.listTreeView.header().setResizeMode(2, QtWidgets.QHeaderView.ResizeToContents) self.listTreeView.header().setResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
@ -666,6 +672,9 @@ class MainWindow(QtWidgets.QMainWindow):
if self.listTreeView.header().width() < (NarrowTabsWidth+self.listTreeView.header().sectionSize(3)): if self.listTreeView.header().width() < (NarrowTabsWidth+self.listTreeView.header().sectionSize(3)):
self.listTreeView.header().resizeSection(3,self.listTreeView.header().width()-NarrowTabsWidth) self.listTreeView.header().resizeSection(3,self.listTreeView.header().width()-NarrowTabsWidth)
else: else:
if IsPySide2:
self.listTreeView.header().setSectionResizeMode(3, QtWidgets.QHeaderView.Stretch)
if IsPySide:
self.listTreeView.header().setResizeMode(3, QtWidgets.QHeaderView.Stretch) self.listTreeView.header().setResizeMode(3, QtWidgets.QHeaderView.Stretch)
self.listTreeView.expandAll() self.listTreeView.expandAll()
except: except: