Results 1 to 2 of 2

Thread: Jump to a cell in QTableView

  1. #1
    Join Date
    Jun 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Jump to a cell in QTableView

    Hello all,

    I'm basically making a spreadsheet, and I'm currently implementing a 'find' feature.

    Two questions

    1) Once I found the cell with the request content, how do I force the QTableView to 'jump' to that cell? By 'jump', I mean QTableView by itself moves to that cell and shows it(it might pages and pages of cells).

    2) Secondly, I feed a QAbstractTableModel to a QSortFilterProxyModel and the proxy is used for the model for the QTableView. If I were to find a cell with a given text and save it for future use(like "Find Next" begins searching from last occurence), and then the view changed, would that cell information(say row and col) be now invalid? It appears to be the case, so how would I go about implementing a 'find next' feature that can handle this type of logic?

    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Jump to a cell in QTableView

    1) QAbstractItemView::scrollTo()
    2) Sorting or filtering in the view will invalidate QModelIndexes (or leave them pointing in the wrong place). Doing these things, especially sorting, will also invalidate the idea of the 'next' match anyway. You could store a QPersistentModelIndex which should only become invalid if the cell is actually removed, or retrieve some other unique identifier for the cell from the underlying model and find the cell using that when next required.

Similar Threads

  1. how remove a cell in qtableview
    By breakthecode in forum Newbie
    Replies: 1
    Last Post: 6th December 2011, 18:30
  2. How to tell if QTableView cell is visible ?
    By steviekm3 in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2009, 10:04
  3. How to tell if cell in QTableView is visible ??
    By steviekm3 in forum Qt Programming
    Replies: 3
    Last Post: 27th February 2009, 17:57
  4. how to get data from cell of QTableview
    By yleesun in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2009, 14:31
  5. How to select a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 6
    Last Post: 6th February 2008, 13:20

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.