Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Reading order after Drag & Drop in QSortFilterProxyModel
QtWS25 Last Chance

Reading order after Drag & Drop in QSortFilterProxyModel

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 405 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DaveK 0
    wrote on last edited by
    #1

    I have a QTableView that I would like to allow the user to sort alphabetically by column, and/or by dragging and dropping entire rows.

    My problem is I do not know how to read the order of the rows as they are currently displayed by the view if the user has used drag and drop to reorder them.

    So far I have a QTableView displaying a QSortFilterProxyModel with a source model of a QStandardItemModel. In my tableview I have set:

    ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableView->verticalHeader()->setSectionsMovable(true);
    mySortProxyModel->setDynamicSortFilter(true);
    ui->tableView->setSortingEnabled(true);
    

    With this the user is able to sort by column and/or drag rows around.

    When I loop through my proxymodeI I can get the order of the rows as if the user has only sorted by columns, but not if they have also moved rows around it has no affect.

    How can I get the final order of rows as shown in the view, regardless of how the user sorted or drag and drop'd them in that order?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved