Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set ResizetoContent for a single column in TableWidget?
sysla1 last edited by sysla1
I am new to Qt and I am using PyQt 5.8.
I had my columns set to resizeColumnsToContents() but when setting setStretchLastSection(True), the table is always resizing to fit the content, even though I am manually setting the setStretchLastSection(True) once more.
Is there anything I can do to prevent it from doing so? I thought about setting 6 of my 7 columns to resizetoContent, so the StretchLastSection won't be overwritten, but I can't seem to find a way to do so.
(setStretchLastSection(True) is also set to true through Qt-Designer)
my table is called table_1. my current code is below:
self.table_1.resizeRowsToContents() self.table_1.resizeColumnsToContents() self.table_1.verticalHeader().setStretchLastSection(True)
thanks, I am open for constructive critics.
VRonin last edited by
What Qt version are you using?
sysla1 last edited by
Oups, Qt 5.8
VRonin last edited by VRonin
http://doc.qt.io/qt-5/qheaderview.html#setSectionResizeMode-1 lets you set the resize mode for each column
my columns set to resizeColumnsToContents() but when setting setStretchLastSection(True)
verticalHeader is for the rows, horizontalHeader is for the columns