[Qt-interest] Sorting a tableview

Alessandro Vanzulli alessandro.vanzulli at gmail.com
Thu Mar 5 10:57:57 CET 2009


Hi,
you have to use the QSortFilterProxy model betwen your model and the
QTableView.

In this way, the sort operation are performed from the QSortFilterProxy and
other operation (data and setdata) are redirected from the proxy to the
model.

Bye.

Alessandro

On Thu, Mar 5, 2009 at 10:27 AM, Zine eddine Bendjaballah <
zineeddine.b at gmail.com> wrote:

> Hi,
>
> In my program I use a QTableView widget to display data from a
> QAbstractTableModel object.
> The tableview displays two columns, I would like to make the first one
> sortable, when clicked.
> I've added these two lines:
>
> tableView->setSortingEnabled(true);
> tableView->sortByColumn(0);
>
> The sorting sign did appear on the first column, but when I click this
> column, the sorting didn't work.
>
> So, what did I forgotten?
>
> Regards.
>
> --
> 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/20090305/1752c739/attachment.html 


More information about the Qt-interest-old mailing list