[Qt-interest] [SOLVED] Responding to when a QSortFilterProxyModel is initialized

Jeffrey Brendecke jwbrendecke at icanetix.com
Mon Sep 27 21:32:12 CEST 2010


> // This is the first item in the proxy, which sorts and filters, so may not
> be the same as the first item in the 'core' model.
> const QModelIndex firstItem = view->model()->index(0, 0);
>
> You can connect to the modelReset() signal to know when the resources are
> refreshed. It is emitted when you call endResetModel in the 'core' model
> and emitted symmetrically by the proxy.
>
> HTH, and if it doesn't I guess I didn't understand the question :).
>
> All the best,
>
> Steve.
>
> > It is well documented how to respond to user selection changes in the
> > view, but unclear how to know when the QTableView has been initialized
> > with new data after a refresh so that a request can be made to actually
> > show the resource referenced by the first item in the table after the
> > refresh.
> >
> > Is this something the model should initiate delivering the resource? It,
> > however, does not know what is first item in the table is given the
> > QSortFilterProxyModel.
> >
> > Trying to catch the request in the model's implementation of data() is
> > too resource intensive given the volume of requests made on a refresh. As
> > I mentioned, it is expensive to actually retrieve the resource.
> >
> > Thank you very much for any assistance.
> >
> > Sincerely,
> >
> > Jeffrey Brendecke
> >
> > Managing Director
> > icanetix Software Systems and Consulting GmbH
> > Untere Hagenstrasse 26
> > 91217 Hersbruck
> > Germany
> >
> > Commercial Registry B 25317 Nuremberg, Germany
> > VAT-ID: DE250213502
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

--------------------
Date: Monday 27 September 2010 14:07
From: Stephen Kelly <steveire at gmail.com>
To: qt-interest at trolltech.com
Cc: 
Subject: Re: [Qt-interest] Responding to when a QSortFilterProxyModel is 
initialized
--------------------
Thanks for the response!

This got me going in the right direction:
> const QModelIndex firstItem = view->model()->index(0, 0);

I had overlooked that it was that simple to get the first item in the proxy 
model that way.

The rest was setting up signals and slots so that after the model was 
refreshed:
* Refreshing the model sent a notification to this effect to the view.
* The model then notified the view to make a request for the resource via a 
signal.
* The view responded, mapped the proxiedRowNo at zero to the sourceRowNo and 
sent a request to the sourceModel for the currentRowNo via a signal.
* After the resources were ready, the model notified the view via a signal 
that the resources had been retrieved and were ready.
* The view sent a signal to the editor to load the resources from the model.

Changing the selection was a little different in that it sent the signal to 
the model mentioned above to get the resource at the current sourceRowNo.

The editor could then respond rather ignorantly to notifications of resource 
availability.

Sincerely,

Jeffrey Brendecke

Managing Director
icanetix Software Systems and Consulting GmbH
Untere Hagenstrasse 26
91217 Hersbruck
Germany

Commercial Registry B 25317 Nuremberg, Germany
VAT-ID: DE250213502



More information about the Qt-interest-old mailing list