[Qt-interest] TableView and QSortFilterProxyModel

Alessandro Vanzulli alessandro.vanzulli at gmail.com
Sun Mar 8 20:59:42 CET 2009


Hi,
it is correct that the QTableView provides you always the same index
(attention, it is the QModelIndex that does not change when you perform any
sort or filter operation).

Using the QModelIndex object, you shall access to your internal model and
change the data. In this way, the index is not related to the presentation
of data and, any change on the data via the Model object, are automatically
redisplayed on the QTableView.

Bye.

Alessandro



On Sun, Mar 8, 2009 at 6:37 PM, Zine eddine Bendjaballah <
zineeddine.b at gmail.com> wrote:

> Hi,
>
> In my program I'm using a QTableView to display items from a model.
> To edit an item I click on the tableview and after clicking on a button the
> following code is running:
>
> QModelIndex modelIndex;
> modelIndex = tableview->currentIndex();
>
> till now I always get the correct index of the item clicked in the
> tableview.
>
> Now, when I added a QSortFilterProxyModel object to allow the tableview to
> be sorted the issue occurred.
>
> After clicking on the column header, the items are sorted, and when I click
> on the item I want to edit tableview->currentIndex() retruns the index of
> the original item before the sorting was executed.
>
> How to correct this?
>
> Cheers.
>
> --
> Zine Eddine Bendjaballah
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090308/4b5f6be3/attachment.html 


More information about the Qt-interest-old mailing list