Guest User

QHeaderView default sort indicator order

a guest
Sep 26th, 2018
229
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×