Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Progressbar in qml
Qt 6.11 is out! See what's new in the release blog

Progressbar in qml

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.6k 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.
  • B Offline
    B Offline
    brasscs1
    wrote on last edited by
    #1

    Can someone show me howto properly inc a progress bar in qml
    my code is below. I see no output until the function is completed. Blocking issue???

    property int showProgressValue:0

    function doAddPlaylist() {
    for(var i=0;i<jukeboxListbox.count;i++) {
    showProgressValue = (i+1)*100/jukeboxListbox.count;
    // pb.value = (i+1)*100/jukeboxListbox.count;
    Services.addPlaylist1(i); // cpp mysql add record works correctly
    }
    }

    ProgressBar {
    id:pb
    minimumValue: 0
    maximumValue: 100
    value: showProgressValue
    }

    1 Reply Last reply
    0
    • J Offline
      J Offline
      johnsmith
      wrote on last edited by
      #2

      As a workaround, instead of setting the property, try triggering a timer inside the loop, and have the action of the timer be the updating of the progress bar's value, and see if that works.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        brasscs1
        wrote on last edited by brasscs1
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • B Offline
          B Offline
          brasscs1
          wrote on last edited by
          #4

          Ok here is try #2. The results were the same. See the output below

          // Timer to show off the progress bar
          Timer {
          id: simpletimer
          interval: 100
          repeat: false
          running: false
          onTriggered: {
          console.log('timer triggered');
          showProgress.value < showProgress.maximumValue ? showProgress.value += 1.0 : showProgress.value = showProgress.minimumValue
          }
          }
          function doAddPlaylist() {
          for(var i=0;i<jukeboxListbox.count;i++) {
          showProgressValue = (i+1)*100/jukeboxListbox.count;
          console.log('showProgressValue is ' + showProgressValue);
          Services.addPlaylist1(i); // cpp mysql add record
          //simpletimer.running=true;
          simpletimer.start();
          }
          }

          ProgressBar {
          id: showProgress
          minimumValue: 0
          maximumValue: 100
          value: 0
          Text {
          anchors.horizontalCenter: parent.horizontalCenter
          text: value + '%'
          }
          }

          qml: showProgressValue is 4
          qml: showProgressValue is 8
          qml: showProgressValue is 12
          qml: showProgressValue is 16
          qml: showProgressValue is 20
          qml: showProgressValue is 24
          qml: showProgressValue is 28
          qml: showProgressValue is 32
          qml: showProgressValue is 36
          qml: showProgressValue is 40
          qml: showProgressValue is 44
          qml: showProgressValue is 48
          qml: showProgressValue is 52
          qml: showProgressValue is 56
          qml: showProgressValue is 60
          qml: showProgressValue is 64
          qml: showProgressValue is 68
          qml: showProgressValue is 72
          qml: showProgressValue is 76
          qml: showProgressValue is 80
          qml: showProgressValue is 84
          qml: showProgressValue is 88
          qml: showProgressValue is 92
          qml: showProgressValue is 96
          qml: showProgressValue is 100
          qml: timer triggered

          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