Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTableView resize columns for non-editable data
Please could any one help me, so I have readonly data into QTableView but I need can resize columns width (Interactive). How can do that?
Thanks a lot.
What has readonly data to do with resizing the header? There are completely independent of each other.
Ketan__Patel__0011 last edited by Ketan__Patel__0011
Use NoEditTriggers Mode For ReadOnly
use this code for fit columns in your tableview
@Christian-Ehrlicher because QTreeView::setEnabled(false) make disabled resize header columns.
You did not wrote this - you said
for non-editable datawhich is something completely different.
QWidget::setEnabled() completely disables the widget - so no that's not possible in this case (and I don't see a reaons why it should)
@Christian-Ehrlicher I need user might be resize columns but can not change the data items.
but can not change the data items.
Please see the post from @Ketan__Patel__0011 - and I also already said that editable and enable/disable are two different things! A disabled widget does not allow any user interaction because ... it is disabled.
@Christian-Ehrlicher yeah but there not working correct. In my QTableView has one item is check box and another combox and I can check and popup them. :-(
So, I need doing the same as disabled but resizing headers are available.
Then fix your model to not allow changing the checkbox state when it should be read only.
Disabling a widget is wrong in this case.
@Christian-Ehrlicher thank you, looks good solution for me.