Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. sorting
    Log in to post

    • UNSOLVED Sort Q3D Scatter Data Array that contains many QVector3D.
      General and Desktop • sorting • • Elthon  

      1
      0
      Votes
      1
      Posts
      22
      Views

      No one has replied

    • UNSOLVED Default sort indicator order in QHeaderView
      General and Desktop • qtableview qheaderview sorting • • MrBolton  

      7
      1
      Votes
      7
      Posts
      3976
      Views

      I know the topic is quite old, but I experienced the exact same issue and this thread was popping up in my search. So, adding a QSortFilterProxyModel and enabling sorting with setSortingEnabled(true) sorts the table in descending order. I got the correct order when I explicitly specifying the order via indicator right before enabling the sort: table->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder); table->setSortingEnabled(true);
    • SOLVED SQLite and QTableView: Custom sorting is slow
      General and Desktop • qtableview sqlite sorting • • YuriQ  

      2
      0
      Votes
      2
      Posts
      1141
      Views

      I created custom model which works fast enough. It fetches and writes data using queries. Seems like working solution.
    • SOLVED Unsorted QVector
      General and Desktop • qvector sorting • • sayan275  

      11
      0
      Votes
      11
      Posts
      2472
      Views

      I got it done by the below code QFileInfoList filelistinfo = dir.entryInfoList(); for(const QFileInfo &fileinfo: filelistinfo) imagePath.push_back(fileinfo.absoluteFilePath()); std::sort(imagePath.begin(), imagePath.end(), [](const QString & a, const QString & b) -> bool { return QFileInfo(a).baseName().toInt() < QFileInfo(b).baseName().toInt(); }); qDebug()<<imagePath;
    • SOLVED QtableView setSortingEnabled  forcing sortByColumn()
      General and Desktop • qtableview qt5.9 sorting qtableview c++ • • mapuna  

      23
      0
      Votes
      23
      Posts
      20394
      Views

      You could set default sorting column to -1 by QHeaderView::setSortIndicator like this yourTableView->horizontalHeader()->setSortIndicator(-1, Qt::AscendingOrder); before running yourTableView->setSortingEnabled(true); because QTableView::setSortingEnabled uses QHeaderView::sortIndicatorOrder and QHeaderView::sortIndicatorSection to identify by which column should model be sorted. Note that documentation of QHeaderView::setSortIndicator tells that not all models support setting sort column to -1 and may even crash in this case.
    • UNSOLVED How to prevent QTableView/QTreeView doing query/sorting multiple times?
      General and Desktop • qtableview qtreeview sorting • • JonB  

      11
      0
      Votes
      11
      Posts
      4973
      Views

      @MrBolton Sorry, I really don't understand your comment. Precisely the point is that with "bigger data sets" you would have to fetch all the data, which is incredibly slow and may well exceed available memory. (OTOH, if the dataset is "small" the overhead of re-query compared to holding all the previous rows locally is also "small".) As a rule of thumb, one always wants as much work to be done at the server side as possible, not client side. Let's say the table has a million rows and the query I want to pose is: SELECT * FROM table ORDER BY column LIMIT 100 Very approximately, pushing the ORDER BY to the server instead of into a QSortFilterProxyModel will run 10 thousand times faster and use one ten-thousandth of the client memory. That's why I would be very careful before advising people to use QSortFilterProxyModel without understanding the ramifications!
    • UNSOLVED How to permanently sort a QStandardItemModel?
      General and Desktop • c++ qtableview qstandarditemmo sorting • • stor314  

      3
      0
      Votes
      3
      Posts
      1365
      Views

      Put a QSortFilterProxy model in-between. then save from the proxy instead of the main model. P.S. connect(currentTableHeader, SIGNAL(sectionClicked(int)), this, SLOT(on_sectionClicked(int))); and void mainWidget::on_sectionClicked(int index) are useless. this is the default behaviour of QTableView, you don't have to implement it manually
    • SOLVED QTableView sorting and headers issue
      General and Desktop • qtableview header sorting • • mjsurette  

      2
      0
      Votes
      2
      Posts
      949
      Views

      The solution was to explicitly call sort after the call to invalidate with setSortingEnabled set to false. Both invalidate and sort were necessary
    • UNSOLVED sorting qlistwidget items
      General and Desktop • qlistwidget sorting • • Lorence  

      6
      0
      Votes
      6
      Posts
      4148
      Views

      @Lorence now its working, i dont know what happens yesterday
    • SOLVED How does QTreeWidgetItem::sortChildren sort?
      General and Desktop • sorting qtreewidgetitem • • Jakob  

      7
      0
      Votes
      7
      Posts
      4220
      Views

      As a first go I tried the suggestion by @SGaist, which turned out to do exactly what I need for now. We're writing a lot from scratch, so for the future I'll certainly keep the idea of @kshegunov in mind, since it sounds a bit more flexible, so it may be required to support more advanced use cases coming our way in the (near) future. Thanx to both!
    • GridView yPosition changes when sorting
      QML and Qt Quick • flickable gridview sorting • • pholz  

      1
      0
      Votes
      1
      Posts
      550
      Views

      No one has replied

    • [solved]Problem in QSettings with no sorting
      General and Desktop • qsettings sorting • • beidaochuan  

      3
      0
      Votes
      3
      Posts
      2533
      Views

      @alex_malyu i will add unique id to every group and add group to QStringList so that i can get a order childGroup.
    • synchronize two QabstractItemModel on Single Common Column
      General and Desktop • qwidget qtableview qabstractitemmo qheaderview qwindow sorting custom item • • Zee_07  

      1
      0
      Votes
      1
      Posts
      541
      Views

      No one has replied

    • [Solved]T he description about sorting in Model/View Qt document maybe wrong?
      General and Desktop • qtreeview model-view sorting • • Enderson  

      3
      0
      Votes
      3
      Posts
      2310
      Views

      Sort the tree view by click a column. Set the view can be sorted by click the "header". treeView_->setSortingEnabled(true); Connect the header signal to a slot made by you. connect(treeView_->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), treeModel_, SLOT(sortByColumn(int, Qt::SortOrder))); In the slot, call the sort() virtual function of the model. sort() virtual function is a virtual function of QAbstractItemModel, and one should override it. void TreeModel::sortByColumn(int column, Qt::SortOrder order) { sort(column, order); } Override the sort() function as your model should do. emit dataChanged(QModelIndex(), QModelIndex());from a model to update the whole tree view.