Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Best way to make Db calls - Qt
Qt 6.11 is out! See what's new in the release blog

Best way to make Db calls - Qt

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 1.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi,

    In my app, I have to make a lot of db calls while the app is running. I am making all of those calls on the main thread. The application ui freezes frequently. I suspect the db calls that I am making for this.

    Do you think making Db calls on main thread is a good approach? Shall I move them to a separate thread?
    If so, can you please suggest a better way? I have been using threads in the app as well but I am creating separate classes for this which derive from @QThread @class. Is there a way in which I could execute a time-expensive operation in a separate block which will run in a separate thread something like the way it happens in java?

    I want a solution in which I will not have to create a separate thread class to do a task. Please suggest.

    Thanks

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by
      #2

      There is no way but use a separate thread.
      Also in Java you have to create a separate thread. So, I don't know what are you refer to when you say "the way it happens in java?".

      Anyway, Qt offers solutions to avoid to explicit create a subclass of QThread. And the solution is the Qt Concurrent module: http://qt-project.org/doc/qt-5.1/qtconcurrent/qtconcurrent-index.html

      With Concurrent module you can "submit" some function to run concurrently with the main thread with the possibility to realize also parallel algorithms (if you want).

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        thanks that was helpful

        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