Hi,

I am in middle of developing a database front-end, and I’m employing the QSqlTableModel together with a QtableView widget among others in order to accomplish this task.

I came across several issues using them both, which I think causes one to conclude that those components are not really suitable for real-world database applications. I hope that someone can prove me wrong.

So, let’s start listing them:

1. view->resizeColumnsToContents() does not resize the columns properly, i.e I have got a column with double values, it get’s resized to show the integer part of the number where the fractional (the digits after the decimal point) gets elided (…). However, funny enough, when double-clicking on the column-separator on the header at run-time it resizes ok.
2. The model->rowsInserted signal will fire on the occasion of a data-change as well, so there’s no real way of determining when a row has actually been added or it has just been changed.
3. On a newly added line (model->insertRow()) I am getting SpinBox editors for numeric columns, but for older rows, I am always getting a regular LineEdit editor.
4. I opted for model()->setEditStrategy(QSqlTableModel::OnRowChange), so every change will get submitted when leaving that row, that will work fine when the user gets into actually editing a cell on a different row. However, if the user clicks away on a different row, or tabs his way through to another row, that change will not get submitted.
5. While a newly (un-submitted) (model->insertRow()) row is present, when the user edit’s a cell of another row, anything typed will be applied onto the new row / record, and not onto the row the user thinks he is editing.

Have anyone came across those issues yet? I know that for problem #1, I can subclass a QItemDelegate and change the sizeHint, but it seems to me to much work-around to re-implement a ItemDelegate just for the sake of that, which is basically a bug on QT’s end. I also know that I can manually submit with submit() or submitAll() before closing that form, but it is esential that those changes gets submitted on row-change (which I believe QSqlTableModel::OnRowChange stands for).

Does anyone know of any good grid that I can incorporate into a QT project that’s serious enough for professional database work? Or does anyone know of any good grid for c++ in general (not MFC)?

How difficult would it be to re-implement a TableModel and View to address those problems? Where would be a good starting point? What would be the best approach to accomplish this?
I would highly welcome any comments on this subject, so please, please come forward with your suggestions.