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

wim.delvaux at adaptiveplanet.com wim.delvaux at adaptiveplanet.com
Sun Dec 13 15:56:21 CET 2009


On Sunday 13 December 2009 06:03:06 Timothy Reaves wrote:
> On Dec 12, 2009, at 11:48 PM, Timothy Reaves wrote:
> > 	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.
>
> 	Oddly enough, if I click the same record a second time in the list view,
> that time it stays selected.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

I propose to look at your code . I use that scenario many times and AFAIK the 
selection does not change




More information about the Qt-interest-old mailing list