PDA

View Full Version : finding data in a qtableview



JeanC
7th March 2008, 17:03
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.

wysota
7th March 2008, 17:35
Take a look at QAbstractItemModel::match().

JeanC
7th March 2008, 18:57
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.

wysota
7th March 2008, 19:00
Take a look at QModelIndex::row().

JeanC
7th March 2008, 19:36
Yes that makes sense.

And thanks again wysota.