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. Multithreading and QProgressBar
QtWS25 Last Chance

Multithreading and QProgressBar

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 1.1k Views
  • 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.
  • H Offline
    H Offline
    HB76
    wrote on last edited by
    #1

    Hello there !

    I am begginer in Qt and I try to devellop an application that use a thread to load a specific file. To do that, I've created a custom thread by inheriting QThread class, and put a signal in this class to send the loading value. This signal is connected to a slot in my mainwindow that set the value of a QProgressBar located in the statusBar area.

    So far, everything works fine.

    But now I would like to have the possibility to open severals files at the same time, and to display the global processing progression in my progressbar. How shall I do to handle all the threads loading progression signals and to connect them to my slot to set the global progress bar value ?

    Thanks for your help !

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

      Hi,

      One way is to first gather the step counts (or whatever reference value you have) for all the files that you are going to load and sum them so you can just increment the progress bar.

      Otherwise you can also have one progress bar per file.

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

      H 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        One way is to first gather the step counts (or whatever reference value you have) for all the files that you are going to load and sum them so you can just increment the progress bar.

        Otherwise you can also have one progress bar per file.

        H Offline
        H Offline
        HB76
        wrote on last edited by
        #3

        @SGaist thanks for your reply.

        I was thinking about something like this but how do you gather the step counts ? Because to sum them, you have to know from which thread the signal is emited ?

        If for example you have :

        int globalProgression = thread1Progression + thread2Progression + ...
        progressBar->setValue(globalProgression);
        

        How do you increment all the threadProgression individualy ?

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

          First thing first: how do you know how many steps each of your thread has ?

          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
          • B Offline
            B Offline
            BobDon
            wrote on last edited by
            #5

            Was this ever solved? I am attempting something similar in python with Qt.

            1 Reply Last reply
            0
            • nageshN Offline
              nageshN Offline
              nagesh
              wrote on last edited by
              #6

              @BobDon one solution would be as follows.
              1)get the count of files that is being opened simultaneously.
              2)If say 6 files are opened, you can set step count as 6*100 = 600
              3)Each processing thread should check filesize and report the delta processed in percentage wise.
              4)Accumulate the percentage progress reported from each thread
              and update the value in Progressbar

              1 Reply Last reply
              1

              • Login

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