progressbar with value inside function
Unsolved
QML and Qt Quick
-
Hello,
I have this code in qml form:
function rownumberupdate() { for(var i = listViewcount; i > 0; i--) { JS.dbimmat(inConversationWith4) var j = i-1 var progress_bar_value = j var date_etape_readed1 = listView.model.get(j).date_etape var date_etape_readed2 = listView.model.get(i).date_etape var hour = parseFloat(listView.model.get(j).temps_bloc_etape) var cycle = parseInt(listView.model.get(j).cycle_etape) if(date_etape_readed1>date_etape_readed2) { JS.dbtimeUpdate( parseFloat(listView.model.get(i).heurecellule)+hour, parseInt(listView.model.get(i).cyclecellule)+cycle, parseFloat(listView.model.get(i).heure_SN_moteur_1)+hour, parseFloat(listView.model.get(i).heure_SO_moteur_1)+hour, parseFloat(listView.model.get(i).heure_SH_moteur_1)+hour, parseInt(listView.model.get(i).cycle_SN_moteur_1)+cycle, parseInt(listView.model.get(i).cycle_SO_moteur_1)+cycle, parseInt(listView.model.get(i).cycle_SH_moteur_1)+cycle, parseFloat(listView.model.get(i).heure_SN_moteur_2)+hour, parseFloat(listView.model.get(i).heure_SO_moteur_2)+hour, parseFloat(listView.model.get(i).heure_SH_moteur_2)+hour, parseInt(listView.model.get(i).cycle_SN_moteur_2)+cycle, parseInt(listView.model.get(i).cycle_SO_moteur_2)+cycle, parseInt(listView.model.get(i).cycle_SH_moteur_2)+cycle, parseFloat(listView.model.get(i).heure_SO_helice_1)+hour, parseInt(listView.model.get(i).cycle_SO_helice_1)+cycle, parseFloat(listView.model.get(i).heure_SO_helice_2)+hour, parseInt(listView.model.get(i).cycle_SO_helice_2)+cycle, listView.model.get(j).id ) listView.model.clear() JS.dbimmat(inConversationWith4) } else { JS.dbtimeUpdate( parseFloat(listView.model.get(i).heurecellule), parseInt(listView.model.get(i).cyclecellule), parseFloat(listView.model.get(i).heure_SN_moteur_1), parseFloat(listView.model.get(i).heure_SO_moteur_1), parseFloat(listView.model.get(i).heure_SH_moteur_1), parseInt(listView.model.get(i).cycle_SN_moteur_1), parseInt(listView.model.get(i).cycle_SO_moteur_1), parseInt(listView.model.get(i).cycle_SH_moteur_1), parseFloat(listView.model.get(i).heure_SN_moteur_2), parseFloat(listView.model.get(i).heure_SO_moteur_2), parseFloat(listView.model.get(i).heure_SH_moteur_2), parseInt(listView.model.get(i).cycle_SN_moteur_2), parseInt(listView.model.get(i).cycle_SO_moteur_2), parseInt(listView.model.get(i).cycle_SH_moteur_2), parseFloat(listView.model.get(i).heure_SO_helice_1), parseInt(listView.model.get(i).cycle_SO_helice_1), parseFloat(listView.model.get(i).heure_SO_helice_2), parseInt(listView.model.get(i).cycle_SO_helice_2), listView.model.get(i).id ) listView.model.clear() JS.dbimmat(inConversationWith4) } } }
and I try to have progressBar following "j" value
Rectangle{ ProgressBar{ minimumValue : 0 maximumValue : listViewcount value : progress_bar_value } }
but the bar doesn't move... I suppose the problem is because the value is changing inside function, but how make it working?...
-
Hello @filipdns. A simple manner of achieving what you want to do is to declare the progress_bar_value outside the function. Declare it as a property, so the property binding will be established automatically.
Or you can also give a changing variable as parameter of the function :
ProgressBar { property int aVariable: 0 value: myFunction(aVariable) function myFunction(aVariable) { var j // ... return j } }
Now, the progress bar value will update for each changing of aVariable.
-
Hello, I try that but I got the same result than the code below, the progressbar doesn't move until the loop is completed:
Rectangle{ anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter ProgressBar{ id:progressbar maximumValue: listViewcount minimumValue: 0 value: 0 } } Rectangle { id: input anchors.top: buttonlist.bottom height: Screen.height / 2 function tableupdate() { for( var i = listViewcount; i > 0; i--) { JS.dbimmat(inConversationWith4) var j = i-1 progressbar.value = i var date_etape_readed1 = listView.model.get(j).date_etape var date_etape_readed2 = listView.model.get(i).date_etape var hour = parseFloat(listView.model.get(j).temps_bloc_etape) var cycle = parseInt(listView.model.get(j).cycle_etape) if(date_etape_readed1>date_etape_readed2) { JS.dbtimeUpdate( parseFloat(listView.model.get(i).heurecellule)+hour, parseInt(listView.model.get(i).cyclecellule)+cycle, parseFloat(listView.model.get(i).heure_SN_moteur_1)+hour, parseFloat(listView.model.get(i).heure_SO_moteur_1)+hour, parseFloat(listView.model.get(i).heure_SH_moteur_1)+hour, parseInt(listView.model.get(i).cycle_SN_moteur_1)+cycle, parseInt(listView.model.get(i).cycle_SO_moteur_1)+cycle, parseInt(listView.model.get(i).cycle_SH_moteur_1)+cycle, parseFloat(listView.model.get(i).heure_SN_moteur_2)+hour, parseFloat(listView.model.get(i).heure_SO_moteur_2)+hour, parseFloat(listView.model.get(i).heure_SH_moteur_2)+hour, parseInt(listView.model.get(i).cycle_SN_moteur_2)+cycle, parseInt(listView.model.get(i).cycle_SO_moteur_2)+cycle, parseInt(listView.model.get(i).cycle_SH_moteur_2)+cycle, parseFloat(listView.model.get(i).heure_SO_helice_1)+hour, parseInt(listView.model.get(i).cycle_SO_helice_1)+cycle, parseFloat(listView.model.get(i).heure_SO_helice_2)+hour, parseInt(listView.model.get(i).cycle_SO_helice_2)+cycle, listView.model.get(j).id ) listView.model.clear() JS.dbimmat(inConversationWith4) } else { JS.dbtimeUpdate( parseFloat(listView.model.get(i).heurecellule), parseInt(listView.model.get(i).cyclecellule), parseFloat(listView.model.get(i).heure_SN_moteur_1), parseFloat(listView.model.get(i).heure_SO_moteur_1), parseFloat(listView.model.get(i).heure_SH_moteur_1), parseInt(listView.model.get(i).cycle_SN_moteur_1), parseInt(listView.model.get(i).cycle_SO_moteur_1), parseInt(listView.model.get(i).cycle_SH_moteur_1), parseFloat(listView.model.get(i).heure_SN_moteur_2), parseFloat(listView.model.get(i).heure_SO_moteur_2), parseFloat(listView.model.get(i).heure_SH_moteur_2), parseInt(listView.model.get(i).cycle_SN_moteur_2), parseInt(listView.model.get(i).cycle_SO_moteur_2), parseInt(listView.model.get(i).cycle_SH_moteur_2), parseFloat(listView.model.get(i).heure_SO_helice_1), parseInt(listView.model.get(i).cycle_SO_helice_1), parseFloat(listView.model.get(i).heure_SO_helice_2), parseInt(listView.model.get(i).cycle_SO_helice_2), listView.model.get(i).id ) listView.model.clear() JS.dbimmat(inConversationWith4) } } }