[Qt-interest] TableView and QSortFilterProxyModel
Israel Brewster
israel at frontierflying.com
Mon Mar 9 17:07:10 CET 2009
By "returns the index of the original item before the sorting was
executed" what exactly do you mean? If the item was originally in
position, say, 5,2 are you saying it still returns a model index for
5,2 even though the item is now 1,2 (or whatever)? Or is the problem
that it returns 1,2, even though the index in the model is still 5,2?
You might want to take a look at the functions
"QSortFilterProxyModel::mapFromSource" and
"QSortFilterProxyModel::mapToSource" - depending on what, exactly the
issue is, one of these might help.
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
On Mar 8, 2009, at 9:37 AM, Zine eddine Bendjaballah 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
More information about the Qt-interest-old
mailing list