Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QThread and QSqlDatabase example
Forum Updated to NodeBB v4.3 + New Features

[Solved] QThread and QSqlDatabase example

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 4.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sam
    wrote on last edited by
    #1

    Is there any example/ reference for QThread + QSqlDatabase ?

    TIA

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Hi!
      I don't know will it be helpful but:
      "http://qt-project.org/forums/viewthread/22125/":http://qt-project.org/forums/viewthread/22125/
      "threads-and-the-sql-module":http://qt-project.org/doc/qt-4.8/threads-modules.html#threads-and-the-sql-module
      In one of my projects i use QTreadPool and QRunable task. In every task i create a copy of DB connection:
      @QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
      db.setHostName(ip);
      db.setDatabaseName(db_name);
      ...
      db.open();@

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #3

        Thanks for the links , Can you provide an idea about the implementation, a basic skeleton will be sufficient.

        Regards
        Soumitra

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          I'll try. What is your goals, what you try to do?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on last edited by
            #5

            I have a scenario where I am loading a QListView with many items from the database. So my requirement is to implement this using QThreads in such a way that the application does not freeze.

            i have gone through the following links:

            • "How To Really, Truly Use QThreads; The Full Explanation":http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
            • "The great QThread Mess":http://www.christeck.de/wp/2010/10/23/the-great-qthread-mess/
            • "You’re doing it wrong…":http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
            • "Threads and QObjects":http://qt-project.org/wiki/ThreadsEventsQObjects#64a093776750c691afdeb133a80f55e2

            I am still looking for a proper example.

            1 Reply Last reply
            0
            • mrdebugM Offline
              mrdebugM Offline
              mrdebug
              wrote on last edited by
              #6

              Have you already got experience with qthreads? If yes you can use one global QSqlDatabase object with synchronization on access to it, or an QSqlDatabase for each thread.

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved