[Qt-interest] How to mix QDataWidgetMapper & QListView on the same model

Timothy Reaves treaves at silverfieldstech.com
Sun Dec 13 05:48:55 CET 2009


	I have a QSqlTableModel.  It is the model for a QListView.  I have it set to show the name column of each row.  I also have a QDataWidgetMapper, backed by the same QSqlTableModel.  I then listen for the signal from the QListView that the selection has changed.  When it does, I get the index of the new selection, and call setCurrentIndex() on the widget mapper.  This populates a form with all of the data for that row.

	The problem I have is that when you click a row, I tell the mapper to select a current index.  The mapper saves the changes to the table model.  This forces the list view to lose its selection.  Now, why on Earth Qt decided that a submit should force all views to loose their selection is beyond me.  I think it's a flaw.  Whatever.  But is there a way out of this catch 22?  It's a very poor user experience for someone to click on a row, have it highlight, then immediately have it revert to normal.



More information about the Qt-interest-old mailing list