1 December 2020
not sure this is the right place to post my question. Can anyone give me an idea or point me in the right direction about how to select items from a tableview and have those items load into a different tableview where they can then be saved as a group (as a state or profile) to recall? Kind of like selecting ingredients for a recipe so to speak.
id 835851715Hi ! Cannot find a simple way to just adjust row height in a QTreeWidget ... :(
Create a derived class of QItemDelegate, and override the sizeHint method - have that call the original sizeHint of the parent class, but modify the height of the QSize returned with the desired height and return the modified QSize, then, construct one of the delegates and pass it to the QTreeWidget with setItemDelegate.
That should do what you're looking for.
FreyaI wonder if it would work (and be easier) to use .setData(col, Qt.SizeHintRole, QSize(...)) on the QTreeWidgetItem?
Oooh SizeHintRole - I forgot about that!
this does though:
from PySide2.QtCore import Qt, QSize
from PySide2.QtWidgets import QTreeWidget, QTreeWidgetItem, QApplication
app = QApplication([])
w = QTreeWidget()
items = [QTreeWidgetItem([str(i)]) for i in range(10)]
size = items[0].sizeHint(0)
items[0].setData(0, Qt.SizeHintRole, QSize(size.width(), 50))
w.setUniformRowHeights(True)
w.insertTopLevelItems(0, items)
w.show()
app.exec_()