PDA

View Full Version : How automatically Select first row after QTableView is created



jijoadoor71
16th May 2014, 07:59
I have a single QTableView(model based).I need to give focus on first row of QTableview while data displaying.While selecting first row, data will displays in line edit boxes.
I am not able to foucus on the first row selection. QSqlQueryModel i am using
If I manually clicked then its working,means first row data displaying in Line edit boxes.please suggest.

my code below

ui->TbleViewUserMgmt->setSelectionMode(QAbstractItemView::SingleSelecti on);
ui->TbleViewUserMgmt->selectRow(0);
ui->TbleViewUserMgmt->setFocus();

anda_skoa
16th May 2014, 08:52
Does it not select the first row?

Or do you want to put the row into edit mode?
See QAbstractItemView::edit() for that

Cheers,
_

jijoadoor71
20th May 2014, 11:50
Using the below code my Table issue resolved

QModelIndexList indexes = ui->TbleViewUserMgmt->selectionModel()->selection().indexes();
QModelIndex index = indexes.at(0);
on_TbleViewUserMgmt_activated(index);