How to set ResizetoContent for a single column in TableWidget?
-
Hello,
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.
-
http://doc.qt.io/qt-5/qheaderview.html#setSectionResizeMode-1 lets you set the resize mode for each column
P.S.
my columns set to resizeColumnsToContents() but when setting setStretchLastSection(True)
self.table_1.verticalHeader().setStretchLastSection(True)
verticalHeader is for the rows, horizontalHeader is for the columns