Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Multithreading and QProgressBar

    General and Desktop
    4
    6
    620
    Loading More Posts
    • 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
      HB76 last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • H
          HB76 @SGaist last edited by

          @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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • B
              BobDon last edited by

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

              1 Reply Last reply Reply Quote 0
              • nagesh
                nagesh last edited by

                @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 Reply Quote 1
                • First post
                  Last post