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. QTableView | catch sort signal and sort
Forum Updated to NodeBB v4.3 + New Features

QTableView | catch sort signal and sort

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.0k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rebel85
    wrote on last edited by
    #1

    I want to reimplement the sorting method for my QTableView (so I can restore a selection). No matter how I try to connect it, I click the TableView header and my method is not called. (there is no output "sortTableView")

    This is how I'm trying to connect the signal:

    @connect(tableView->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(sortTableView(int)));@

    This is how my method looks like:

    @
    void myWindow::sortTableView(int column)
    {
    cout << "sortTableView" << endl;

    //remember the ids of the selected rows
    ...

    bool ascending = (tableView->horizontalHeader()->sortIndicatorSection() == column && tableView->horizontalHeader()->sortIndicatorOrder() == Qt::DescendingOrder);
    Qt::SortOrder order = ascending ? Qt::AscendingOrder : Qt::DescendingOrder;

    tableView->horizontalHeader()->setSortIndicator(column, order);
    tableView->sortByColumn(column, order);

    //restore the selection using the saved ids
    ...
    }
    @

    According to the internet, that should work..
    What am I missing? Any help appreciated!

    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