[Qt-interest] How to mix QDataWidgetMapper & QListView on the same model
Timothy Reaves
treaves at silverfieldstech.com
Sun Dec 13 19:08:24 CET 2009
On Dec 13, 2009, at 9:56 AM, wim.delvaux at adaptiveplanet.com wrote:
> 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.
>
> I propose to look at your code . I use that scenario many times and AFAIK the
> selection does not change
>
What submit policy do you use on your mapper?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091213/59df7532/attachment.html
More information about the Qt-interest-old
mailing list