Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] QDataWidgetMapper, clearing associated QLineEdit's when table is empty
I have been wondering about this for some weeks, but I had some other things to worry about. Still, I've been looking into this every now and then and I can't really figure this out.
I have a QTableView, tied to a QSqlTableModel. I also have a QDataWidgetMapper, which I used to sync the table with a QLineEdit based form where I can enter and edit records from my QSqlTableModel.
The final piece is a function that I use to remove all the records in the table. That works, however, while the table becomes empty as it must, the QLineEdits will still hold the last values after the table has been cleaned.
I could of course blank them "by hand" in the same function I use to erase all the records, but I am wondering if there isn't any more "straight" way to do this.
I use QSqlTableModel::removeRows() along with rowCount() to remove the whole table. As said, the table widget empties itself. But the thing doesn't propagate into the QWidgetMapper for some reason, or maybe that's the intended behaviour...
Thanks for any response, or just for reading :)
I wonder if the index of the mapper is updated while your remove the rows
[quote author="SGaist" date="1377034234"]Hi,
I wonder if the index of the mapper is updated while your remove the rows[/quote]
I don't know what the correct behaviour would be, but the mapper->currentIndex() reports -1 after the removeRows() sentence.
That would be the correct index.
But whether the QDataWidgetMapper should clear the widget's content is more a question for the interest mailing list, you'll find there Qt's developers/maintainers (this forum is more user oriented)
[quote author="SGaist" date="1377099893"]That would be the correct index.
But whether the QDataWidgetMapper should clear the widget's content is more a question for the interest mailing list, you'll find there Qt's developers/maintainers (this forum is more user oriented)[/quote]
Oh, I am not really concerned about that for now.
Don't take me wrong, I am concerned about some things, and would be willing to help a bit, but my own ignorance would be nothing but a hindrance to any mailing list for now.
I was just wondering if that was the intended behaviour of a QDataWidgetMapper instance.
Even within my limited understanding of nowadays Qt, I can think of several ways to clean the fields in a more or less automated way.
Thank you for clearing my doubt :)
You welcome !
This question would as valid as any, don't worry,
Happy coding :)