Progressbar in qml



  • 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
    }



  • 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.



  • This post is deleted!


  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.