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. What is the proper way to set QProgressBar to update from the logic layer? [Solved]
Forum Updated to NodeBB v4.3 + New Features

What is the proper way to set QProgressBar to update from the logic layer? [Solved]

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 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.
  • G Offline
    G Offline
    GoldenAxe
    wrote on last edited by
    #1

    If I want to update a QProgressBar on the view layers from a loop on the logic layer (such as each iteration will update the progress bar), what is the proper way to do that?

    Thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @
      forever { // or any other loop you have
      // do your calculations
      qProgressBar->setValue(currentVal);
      qApp->processEvents();
      }
      @

      "::setValue()":http://qt-project.org/doc/qt-4.8/qprogressbar.html#value-prop

      Alternatively, you can emit some signal from your logic, and connect to it in your GUI.

      (Z(:^

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GoldenAxe
        wrote on last edited by
        #3

        The first solution you suggested, requires me to send as parameter the progress bar from the view layer to the logic layer?

        The second suggestion requires me to emit signal in each iteration?

        Thanks

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Yes. Now you mention it, I can see it might not be exactly what you want.

          Yes and no. You have to emit the signal to update the progress bar, but you don't have to do it every time if you don't want to.

          (Z(:^

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AlekseyOk
            wrote on last edited by
            #5

            ... or you can add timer and update progress bar value on timeout event via signal or setValue(value)...

            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