john_crichton
2nd May 2008, 12:24
Hello, I am currently working on a database application that has two threads - the query thread and the gui thread. The data is sent from query thread to gui thread in form of QSqlQueryModel*. Everything works fine and the application is operational but still I would like to have my QSqlQueryModel *model protected so that only one thread at a time can use it. In the gui thread I have the following piece of code:
ui.tableView->setModel(model);
ui.tableView->setColumnWidth(0, 50);
ui.tableView->setColumnWidth(1, 250);
ui.tableView->setColumnWidth(2, 250);
ui.tableView->setColumnWidth(3, 100);
ui.tableView->show();
In the query thread I have the following code:
model->setQuery(*query);
How could I achieve the following: When one piece of code starts the other would not get executed until the first one has finished.
Thanks in advance for any help you offer.
ui.tableView->setModel(model);
ui.tableView->setColumnWidth(0, 50);
ui.tableView->setColumnWidth(1, 250);
ui.tableView->setColumnWidth(2, 250);
ui.tableView->setColumnWidth(3, 100);
ui.tableView->show();
In the query thread I have the following code:
model->setQuery(*query);
How could I achieve the following: When one piece of code starts the other would not get executed until the first one has finished.
Thanks in advance for any help you offer.