SHARE
TWEET

QHeaderView default sort indicator order

a guest Sep 26th, 2018 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <QApplication>
  2. #include <QStandardItemModel>
  3. #include <QTableView>
  4. #include <QHeaderView>
  5. #include <QSortFilterProxyModel>
  6.  
  7. #include <QDebug>
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11.     QApplication app( argc, argv );
  12.     QStandardItemModel *model=new QStandardItemModel(&app);
  13.  
  14.  
  15.     model->appendRow(new QStandardItem(QString::number(1)));
  16.     model->appendRow(new QStandardItem(QString::number(4)));
  17.     model->appendRow(new QStandardItem(QString::number(2)));
  18.     model->appendRow(new QStandardItem(QString::number(9)));
  19.     model->appendRow(new QStandardItem(QString::number(5)));
  20.     model->appendRow(new QStandardItem(QString::number(3)));
  21.  
  22.     QTableView* tableView = new QTableView();
  23.  
  24.     QSortFilterProxyModel* sortModel = new QSortFilterProxyModel(tableView);
  25.     sortModel->setSourceModel(model);
  26.  
  27.     tableView->setModel(sortModel);
  28.     tableView->setSortingEnabled(true);
  29.     tableView->show();
  30.  
  31.     return app.exec();
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top