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. qthread or qtconcurrent.
Forum Updated to NodeBB v4.3 + New Features

qthread or qtconcurrent.

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 1.5k 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
    s002wjh
    wrote on last edited by
    #1

    if i have a sort function in ascend order. then plot the data in QT pixelmap and color it base on the value. I have few of these pixelmap window, each run the same sort function but each has different input data, and data update in the ms. to run these concurrently, can this type operation achieve by qthread/movetothread type or using qtconcurrent? or something better.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Threading is threading, QtConcurrent simply offers you high level tools that avoids you the need to manage threads yourself.

      QtConcurrent will likely fill the bill if used correctly.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Threading is threading, QtConcurrent simply offers you high level tools that avoids you the need to manage threads yourself.

        QtConcurrent will likely fill the bill if used correctly.

        S Offline
        S Offline
        s002wjh
        wrote on last edited by
        #3

        @SGaist

        if my sort function is declare in a Qwidget class. do i need to put that function in Qobject or Qthread class before using

        Qtconcurrent run?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Did you read the documentation about QtConcurrent run ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            Did you read the documentation about QtConcurrent run ?

            S Offline
            S Offline
            s002wjh
            wrote on last edited by
            #5

            @SGaist
            i read this

            https://doc.qt.io/qt-5.10/qtconcurrentrun.html

            it didn't mention if function declare in Qwidget class is fine for qtconcurrent. The reason i ask is because movetothread require Qobject etc.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Watch out, you're not allowed to modify GUI elements from other threads.

              You should take that kind of thing into account when designing your application.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply
              1
              • SGaistS SGaist

                Watch out, you're not allowed to modify GUI elements from other threads.

                You should take that kind of thing into account when designing your application.

                S Offline
                S Offline
                s002wjh
                wrote on last edited by
                #7

                @SGaist

                ok thanks, but if my function only doing some background calculation(for example sorting), it just happen to be declare in Qwidget. it should be fine right?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  It should but it won't be clean.

                  You should rather properly separate responsibilities. Otherwise you are going to end up with code that will be difficult to maintain and understand.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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