Results 1 to 5 of 5

Thread: finding data in a qtableview

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default finding data in a qtableview

    I am searching for a way to locate data in a qtableview.

    For instance I want to know the row where the first cell has text 'something'.
    What I'm doing now to achieve this, is making a query with the same filter and sorting as the model that feeds the table and then traversing this query till I get to that cell.

    But this method fails if the table gets a sortByColumn() in a column which has exactly the same data in the cells.

    I don't know what sortByColumn exactly does in this case, at least the order of the data is not the same as with the query so this trick does not work then.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: finding data in a qtableview

    Take a look at QAbstractItemModel::match().

  3. #3
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: finding data in a qtableview

    Thanks wysota,

    But this gives me a QModelIndexList, but what I'm searching for is a way to get an int that I can use for table->selectRow().

    For instance if the x'th row of a table in column 1 holds a cell with content 'something' I want a way to look up that row and do a selectRow(x).

    I can't find a relation between a tableview and the content of it's cells.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: finding data in a qtableview

    Take a look at QModelIndex::row().

  5. #5
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: finding data in a qtableview

    Yes that makes sense.

    And thanks again wysota.

Similar Threads

  1. QTableView : accessing the data
    By marvaneke in forum Newbie
    Replies: 10
    Last Post: 30th March 2012, 11:31
  2. Data not being added to my QTableView?
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2007, 14:20
  3. QTableView contextMenuEvent
    By derrickbj in forum Qt Programming
    Replies: 1
    Last Post: 1st March 2007, 16:37
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.