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 with value inside function

progressbar with value inside function

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 930 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.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by filipdns
    #1

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

    1 Reply Last reply
    0
    • ibiaI Offline
      ibiaI Offline
      ibia
      wrote on last edited by ibia
      #2

      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.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        filipdns
        wrote on last edited by
        #3

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