QSqlTableModel resize on edit
-
Is there a way to resize the column to content after user put a proposed change in a cell but still hasn't submitted the change?
So QSqlTableModel set to QTableView with ManulSubmit as the EditStrategy.
A user enters cell but he cannot see entire text after he pressed enter.I can capture the setData that is triggered after submit but this is too late.
I have set resizepolicy on view and on columns but it's not dynamic.sql_model_serie->setTable("DokSerieMag"); sql_model_serie->select(); ui->TV_serie->setModel(sql_model_serie); ui->TV_serie->hideColumn(ui->TV_serie->header_column("dokseria_id")); sql_model_serie->setEditStrategy(QSqlTableModel::OnManualSubmit); ui->TV_serie->resizeColumnsToContents(); ui->TV_serie->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); ui->TV_serie->horizontalHeader()->setResizeContentsPrecision(-1); for (int col = 0; col < ui->TV_serie->model()->columnCount(); ++col) ui->TV_serie->resizeColumnToContents(col); ui->TV_serie->horizontalHeader()->setStretchLastSection(true); -
Is there a way to resize the column to content after user put a proposed change in a cell but still hasn't submitted the change?
So QSqlTableModel set to QTableView with ManulSubmit as the EditStrategy.
A user enters cell but he cannot see entire text after he pressed enter.I can capture the setData that is triggered after submit but this is too late.
I have set resizepolicy on view and on columns but it's not dynamic.sql_model_serie->setTable("DokSerieMag"); sql_model_serie->select(); ui->TV_serie->setModel(sql_model_serie); ui->TV_serie->hideColumn(ui->TV_serie->header_column("dokseria_id")); sql_model_serie->setEditStrategy(QSqlTableModel::OnManualSubmit); ui->TV_serie->resizeColumnsToContents(); ui->TV_serie->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); ui->TV_serie->horizontalHeader()->setResizeContentsPrecision(-1); for (int col = 0; col < ui->TV_serie->model()->columnCount(); ++col) ui->TV_serie->resizeColumnToContents(col); ui->TV_serie->horizontalHeader()->setStretchLastSection(true); -
@Seb-Tur
FWIW did you try callingresizeColumnsToContents()again immediately after the user finished editing the cell?I didn't find any onEditingFinshed signals
I just found some other that are triggered only after data is submitted.
Normally a user can edit multiple cells and hit Submit only after all of them are ready - in the meantime the edited ones that do not fit to column are truncated with .... -
I didn't find any onEditingFinshed signals
I just found some other that are triggered only after data is submitted.
Normally a user can edit multiple cells and hit Submit only after all of them are ready - in the meantime the edited ones that do not fit to column are truncated with ....I would be rather annoyed when the cells would resizing during my edits... even afterwards it will not be a good ui design.
-
I didn't find any onEditingFinshed signals
I just found some other that are triggered only after data is submitted.
Normally a user can edit multiple cells and hit Submit only after all of them are ready - in the meantime the edited ones that do not fit to column are truncated with ....@Seb-Tur said in QSqlTableModel resize on edit:
I didn't find any onEditingFinshed signals
Search QAbstractItemView Class (inherited by your
QTableView) for everything to do withitemDelegate. Then QAbstractItemDelegate Class for stuff to do withEditor/ModelData. This is how editing in aQTableViewworks. For your purpose you can hopefully avoid having to subclass to overridevirtualmethods (though you could do that) by connecting to void QAbstractItemDelegate::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint = NoHint) signal? -
@Seb-Tur said in QSqlTableModel resize on edit:
I didn't find any onEditingFinshed signals
Search QAbstractItemView Class (inherited by your
QTableView) for everything to do withitemDelegate. Then QAbstractItemDelegate Class for stuff to do withEditor/ModelData. This is how editing in aQTableViewworks. For your purpose you can hopefully avoid having to subclass to overridevirtualmethods (though you could do that) by connecting to void QAbstractItemDelegate::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint = NoHint) signal?