How to set width of one column int a QTableView?
-
Now there's a QTableView with 5 columns.The programme will run on different kinds of computers(defferent size of screen),so I hpoe QTableView will has different width when the programme is running.
The second column of QTableView is a QPushButton that's put on by QStyledItemDelegate.I hope the second column of TableView has fix size,other columns can automtaic change size when the programme run different screen.
Then,I do like this:myTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); myTable->setColumnWidth(1,50);
But It doesn't work,I find in Asistant,the document tell me the fun doesn't work if I use setSectionResizeMode() brfore.
I hope the width of second column is fixed and other columns is stretch.How to achieve it? -
Now there's a QTableView with 5 columns.The programme will run on different kinds of computers(defferent size of screen),so I hpoe QTableView will has different width when the programme is running.
The second column of QTableView is a QPushButton that's put on by QStyledItemDelegate.I hope the second column of TableView has fix size,other columns can automtaic change size when the programme run different screen.
Then,I do like this:myTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); myTable->setColumnWidth(1,50);
But It doesn't work,I find in Asistant,the document tell me the fun doesn't work if I use setSectionResizeMode() brfore.
I hope the width of second column is fixed and other columns is stretch.How to achieve it?@qazaq408 What about this one: https://doc.qt.io/qt-5.11/qheaderview.html#setSectionResizeMode-1