Results 1 to 2 of 2

Thread: Protect QSqlQueryModel in two threads

  1. #1
    Join Date
    Apr 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Protect QSqlQueryModel in two threads

    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:
    Qt Code:
    1. ui.tableView->setModel(model);
    2. ui.tableView->setColumnWidth(0, 50);
    3. ui.tableView->setColumnWidth(1, 250);
    4. ui.tableView->setColumnWidth(2, 250);
    5. ui.tableView->setColumnWidth(3, 100);
    6. ui.tableView->show();
    To copy to clipboard, switch view to plain text mode 
    In the query thread I have the following code:
    Qt Code:
    1. model->setQuery(*query);
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Protect QSqlQueryModel in two threads

    I have finished a small test application in Qt 4.3. For now it is a small database with gui to add and delete items and search the database. The application shows the use of QSettings, some use of SQL module and the basic multithreading. It is not finished as I yet don't have the answers to the question from the previous post. Anyway if anyone wants the code of this application feel free to contact me and I'll send it to you. Best regards john_crichton.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.