I'd like to manage width of my columns in a table personally, but after resizing them from the code, I cannot figure out a way to prevent user from resizing them manually. I found out that QTableView
has the columnResized()
slot, and the only ways to do it I see are either subclassing QTableWidget
or resizing columns again and again on the timer event.
Might there be an easier way?
It can be done using :
void QHeaderView::setSectionResizeMode (ResizeMode mode)
void QHeaderView::setSectionResizeMode (int logicalIndex, ResizeMode mode)
The horizontal header is reachable from a QTableWidget
using horizontalHeader()
.
This is it:
ui->tMeal->horizontalHeader()->setSectionResizeMode (QHeaderView::Fixed);
Note that legacy (Qt4) applications should use setResizeMode()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With