Get row datas from QTableview
Solved
General and Desktop
-
Hello!
I try to figure out how i can get a full row from QTableView on the UI.my initial setting( not in the constructor)
void SearchRecord::GetFindThis(const QString& input) { sc->PrepareToFind(input); ui->ShowModel->setSelectionBehavior(QAbstractItemView::SelectRows); ui->ShowModel->setSelectionMode(QAbstractItemView::SingleSelection); ui->ShowModel->setModel(sc->GetTemp()); //sc is a Controller, after some "magic" its prepare the searched input (AKA full name) //GetTemp return with a QSqlQueryModel }
after that i try this to get row(note that this only testing and i know its not that great i want to use a
QStringList
)void SearchRecord::on_ShowModel_pressed(const QModelIndex &index) { qDebug()<<ui->ShowModel->currentIndex(); qDebug()<<index.row(); qDebug()<<index.model()->columnCount(); QString sample=ui->ShowModel->model()->data(index).toString(); qDebug()<<sample; }
i tried
QSqlRecord
but thats dont work because theui->showModel
is a QTableViewmy other thought was that i make another query for the choosen record but i think thats not that great and there is an easier way.
So my question is how i can get a row?
Regards:
Cs' -
What is
on_ShowModel_pressed
connected to?a possible solution would be:
QStringList rowList; for(i=0, maxCol = index.model()->columnCount();i<maxCol;++i) rowList << index.model()->index(index.row(),i).data().toString();