Results 1 to 4 of 4

Thread: Qt4: Sorting QAbstractItemVew inherited view

  1. #1
    Join Date
    Aug 2007
    Location
    Frankfurt / Germany
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt4: Sorting QAbstractItemVew inherited view

    Hi everybody,

    i have a problem with sorting in my view:

    i have implemented my own view (inherited from QAbstractItemView) and my own model (inherited from QAbstractItemModel) and my own Proxy (inherited from QSortFilterProxyModel).

    Everything like inserting data, updating and removing data works fine.

    Now i want to add sorting, so i reimplemented the proxy's lessThan method.

    If i trigger a sort by calling:

    pView->model()->sort(colIndex);

    i see the proxy's lessThan method is called as expected,

    but my view do not update (reorder) its contents.

    If i connect a standard QTableView to my proxy and then enable sorting and then click on an cell-header,
    i also see the proxy's lessThan method is called

    and the table displays the reordered data correctly

    so i think i have missed something in my own view implementation, but i don't know what?

    Does somebody has done this already?

    Greetings,
    Nando

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4: Sorting QAbstractItemVew inherited view

    Have you reimplemented any other methods than lessThan in your proxy? Do you emit proper signals from the model? Does the view listen for them and refreshes itself according to their contents?

  3. #3
    Join Date
    Aug 2007
    Location
    Frankfurt / Germany
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4: Sorting QAbstractItemVew inherited view

    Hi,

    i think my proxy is fine, because if i use my proxy with a standard QTableView,
    then sorting works.

    My model emits dataChanged signal and that works fine. So my view gets the updates.

    I think maybe i have forgotten to overwrite some methods in my view.
    I do not know which methods are called from the (proxy)model if sorting is in progress. dataChanged and currentChanged or rowsRemoved or rowsInserted aren't called.

    Do i manually have to connect my view to some slots ?
    I thought if i call pView->setModel(pProxy) all these connections are done implicitly (because inserting/removing and updating date works fine) ???

    Greetings,
    Nando

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4: Sorting QAbstractItemVew inherited view

    Hard to say without seeing any code. Maybe you are not connected to layoutChanged() or some other signal...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.