gui/experiments: fix Qt compatibility issue with QHeaderView.setResizeMode

This commit is contained in:
Sebastien Bourdeauducq 2015-12-13 19:32:17 +08:00
parent eeb53c5aa5
commit eac2e2ad0b
1 changed files with 7 additions and 3 deletions

View File

@ -132,9 +132,13 @@ class _ArgumentEditor(QtGui.QTreeWidget):
QtGui.QTreeWidget.__init__(self) QtGui.QTreeWidget.__init__(self)
self.setColumnCount(3) self.setColumnCount(3)
self.header().setStretchLastSection(False) self.header().setStretchLastSection(False)
self.header().setResizeMode(0, QtGui.QHeaderView.ResizeToContents) if hasattr(self.header(), "setSectionResizeMode"):
self.header().setResizeMode(1, QtGui.QHeaderView.Stretch) set_resize_mode = self.header().setSectionResizeMode
self.header().setResizeMode(2, QtGui.QHeaderView.ResizeToContents) else:
set_resize_mode = self.header().setResizeMode
set_resize_mode(0, QtGui.QHeaderView.ResizeToContents)
set_resize_mode(1, QtGui.QHeaderView.Stretch)
set_resize_mode(2, QtGui.QHeaderView.ResizeToContents)
self.header().setVisible(False) self.header().setVisible(False)
self.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
self.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel) self.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)