QTableView resize columns for non-editable data
-
Hi all!
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.
-
Use NoEditTriggers Mode For ReadOnly
table_view->horizontalHeader()->setStretchLastSection(true);
use this code for fit columns in your tableview
-
@Christian-Ehrlicher because QTreeView::setEnabled(false) make disabled resize header columns.
-
Christian Ehrlicher Lifetime Qt Championreplied to Alexey Serebryakov on last edited by Christian Ehrlicher
@Alexey-Serebryakov said in QTableView resize columns for non-editable data:
QTreeView::setEnabled(false)
You did not wrote this - you said
for non-editable data
which 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.
-
@Alexey-Serebryakov said in QTableView resize columns for non-editable data:
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.