PDA

View Full Version : how to set row in QListView before showing?



lisarden
29th March 2011, 15:38
Hi folks!

I use QListView to show an Address Book (Name, Surname, Phone1, Phone2 etc). As a pattern I use this example (because I'm really new in QT):
http://qt-articles.blogspot.com/2010/07/how-to-customize-listview-in-qt-using.html

The resulted GUI looks like at my Nokia phone but I want to go further and set a preselected row before the QListView is displayed. When I used QListWidget it had a very good function setCurrentRow(int). For this QListView I need the same function and don't know how implement this (two day of searching..)

please advise

Added after 20 minutes:

Solved by the following code:

QModelIndex i = ui->aBookContact->model()->index(row_to_select, 0);
ui->aBookContact->selectionModel()->setCurrentIndex(i, QItemSelectionModel::SelectCurrent);