Hi all,
I have main window with two tableView widgets. The data has primary key and foreign key and I want to connect it using onclick slot. The idea is to update the second table when click on the first and modify where part in the query.
The problem is that I can get the index of the first table but i need the value. Here is the code of the slot:
{
num = this->db->model->data(this->db->model->index(index.row(), 0)).toString();
this->SBMessageBox("idx: " + num + ".");
}
void SBTable::on_tableView_clicked(QModelIndex index)
{
QString num;
num = this->db->model->data(this->db->model->index(index.row(), 0)).toString();
this->SBMessageBox("idx: " + num + ".");
}
To copy to clipboard, switch view to plain text mode
Thanks in advance!
Added after 49 minutes:
I found a solution:
num = this->ui->tableView->model()->data(
this->ui->tableView->model()->index(index.row() ,
0)).toString();
num = this->ui->tableView->model()->data(
this->ui->tableView->model()->index(index.row() ,
0)).toString();
To copy to clipboard, switch view to plain text mode
One other problem appear now:
How to set the model to the second tableView?
Bookmarks