Results 1 to 3 of 3

Thread: Model sorting vs. selection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2006
    Posts
    20
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Re: QTableView versus QTableWidget

    Hello! After the sorting of my model (derived from the abstract table model, my own file model) the selection on my table view remains on the (now false) place. The problem: my selection is on the view and my sorting is in the model.
    I thought it should work automatically in the view to keep the selection of indexes and not of cells by sorting my model.
    What can You recommend?

    Qt Code:
    1. void FileModel::sort ( int column, Qt::SortOrder order )
    2. {
    3.  
    4. bool (*compare_funk)(const BUFileInfo &a,const BUFileInfo &b)=0; //point to the compare-function
    5. switch (column)
    6. {
    7. case 0:
    8. compare_funk=(order)?BUFileInfo::biggerName:BUFileInfo::lessName;
    9. break;
    10. case 1:
    11. compare_funk=(order)?BUFileInfo::biggerSize:BUFileInfo::lessSize;
    12. break;
    13. case 2:
    14. compare_funk=(order)?BUFileInfo::biggerExt:BUFileInfo::lessExt;
    15. break;
    16. case 3:
    17. compare_funk=(order)?BUFileInfo::biggerDate:BUFileInfo::lessDate;
    18. break;
    19. case 4:
    20. compare_funk=(order)?BUFileInfo::biggerState:BUFileInfo::lessState;
    21. break;
    22. }
    23.  
    24. if(compare_funk)
    25. {
    26. //std::list<BUFileInfo>::sort(fileList.begin(),fileList.end(),compare_funk);
    27. qSort(fileList.begin(),fileList.end(),compare_funk);
    28. emit layoutChanged();
    29.  
    30. }
    31.  
    32. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 14th October 2006 at 18:40. Reason: missing [code] tags

Similar Threads

  1. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 07:52
  2. Sharing Selections between Model and ProxyModel
    By mentat in forum Qt Programming
    Replies: 14
    Last Post: 27th January 2010, 17:31
  3. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  4. QTableWidget Sorting Multiple Selection
    By rhiacasta in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2006, 21:05
  5. QSortFilterProxyModel signal and selection confusion
    By pascal123 in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2006, 16:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.