kode
22nd December 2010, 13:13
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:
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 + ".");
}
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();
One other problem appear now:
How to set the model to the second tableView?
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:
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 + ".");
}
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();
One other problem appear now:
How to set the model to the second tableView?