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. qml QListview updating slow by c++
Forum Updated to NodeBB v4.3 + New Features

qml QListview updating slow by c++

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 499 Views
  • 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
    bladekel
    wrote on last edited by bladekel
    #1

    I'm updating the qml Listview from c++ like;

    in main.cpp;

    listeci frmlisteci;
    engine.rootContext()->setContextProperty("listeElemanlar", &frmlisteci.listeElemanlar);
    

    in Liste.qml;

            ListView{
                id: listeciElemanlar
                anchors.fill: parent
                model: listeElemanlar
                delegate: Text{
                    text: display
                    verticalAlignment: Text.AlignBottom
                    width : parent.width
                    color: textRengi
                    font.pointSize: 30
                    leftPadding: 20
                }}
    

    in listeci.h;

    public:
        QStringListModel listeElemanlar;
    private:
        QStringList userAyarlari;
    

    in listeci.cpp;

    listeci::listeci(QObject *parent) : QObject(parent)
    {
    
        // Kullanıcı ayarları elemanları
        userAyarlari.append("Kullanıcı ayarı 01");
        userAyarlari.append("Kullanıcı ayarı 02");
        userAyarlari.append("Kullanıcı ayarı 03");
        userAyarlari.append("Kullanıcı ayarı 04");
        userAyarlari.append("Kullanıcı ayarı 05");
        userAyarlari.append("Kullanıcı ayarı 06");
        userAyarlari.append("Kullanıcı ayarı 07");
        userAyarlari.append("Kullanıcı ayarı 08");
        userAyarlari.append("Kullanıcı ayarı 09");
        userAyarlari.append("Kullanıcı ayarı 10");
        userAyarlari.append("Kullanıcı ayarı 11");
        userAyarlari.append("Kullanıcı ayarı 12");
        userAyarlari.append("Kullanıcı ayarı 13");
        userAyarlari.append("Kullanıcı ayarı 14");
        userAyarlari.append("Kullanıcı ayarı 15");
        userAyarlari.append("Kullanıcı ayarı 16");
        userAyarlari.append("Kullanıcı ayarı 17");
        userAyarlari.append("Kullanıcı ayarı 18");
        userAyarlari.append("Kullanıcı ayarı 19");
    }
    void listeci::listeGuncelle()
    {
        listeElemanlar.setStringList(userAyarlari);
    }
    

    with these lines, I can successfully create a list and show on qml Listview, when I clicked on a button on qml side by calling

    frmlisteci.listeGuncelle()
    

    But when I do this procedure after a mount,( we can say refreshing the list) the code becoming slow, and waiting on this line:

    listeElemanlar.setStringList(userAyarlari);
    

    What can be the reason ?

    Edit : 1

    I just discover sth.

    On my project, I have 5 qml pages and I'm navigating between the pages with "Stackview".

    Here is the construction of stackview.

            // Sayfa bölmesi
            StackView {
                id: stackci
                initialItem: manuelSayfa
                anchors.fill : sayfaBolmesi
    
                pushEnter: Transition {
                    PropertyAnimation {
                        property: "opacity"
                        from: 0
                        to: 1
                        duration: 0
                    }
                }
                pushExit: Transition {
                    PropertyAnimation {
                        property: "opacity"
                        from: 1
                        to: 0
                        duration: 0
                    }
                }
            }
    
            Component{
                id:manuelSayfa
                Manuel{}
            }
    
            Component{
                id:otomatikSayfa
                Otomatik{}
            }
    
            Component{
                id:ayarlaraGirisSayfa
                AyarlaraGiris{}
            }
    
            Component{
                id:listelerSayfa
                Liste{}
            }
    
            Component{
                id:bilgiSayfa
                Bilgi{}
            }
    

    And I'm navigating the pages with a signal from c++ like;

    on main.qml

        Connections{
            target: sayfaDegistirmeReferansi
            onSayfaDegistir:{
                sayfaDegistir(s)
            }
        }
    
    .......
    
    function sayfaDegistir(sayfa)
        {
             if(sayfa == 100) stackci.push(manuelSayfa)
             .......
        }
    

    on main.cpp

        engine.rootContext()->setContextProperty("sayfaDegistirmeReferansi",&frmkeypad);
    

    My algorithm is like, when I send a signal to qml from c++, it first refresh the list, than open the page.

    The thing that I discovered is, when I refresh the list with MouseArea ( also same with signal from c++), it doesnt make a delay on refreshing the list.

    The difference is, I dont reload the page, only reloading the list....

    So what can be the problem ????

    Edit : 2

    I solved the problem.

    It is caused by stackview. I had used push method for changing the page.

    When I changed push method by replace, everything started to work well.....

    VRoninV 1 Reply Last reply
    2
    • B bladekel

      I'm updating the qml Listview from c++ like;

      in main.cpp;

      listeci frmlisteci;
      engine.rootContext()->setContextProperty("listeElemanlar", &frmlisteci.listeElemanlar);
      

      in Liste.qml;

              ListView{
                  id: listeciElemanlar
                  anchors.fill: parent
                  model: listeElemanlar
                  delegate: Text{
                      text: display
                      verticalAlignment: Text.AlignBottom
                      width : parent.width
                      color: textRengi
                      font.pointSize: 30
                      leftPadding: 20
                  }}
      

      in listeci.h;

      public:
          QStringListModel listeElemanlar;
      private:
          QStringList userAyarlari;
      

      in listeci.cpp;

      listeci::listeci(QObject *parent) : QObject(parent)
      {
      
          // Kullanıcı ayarları elemanları
          userAyarlari.append("Kullanıcı ayarı 01");
          userAyarlari.append("Kullanıcı ayarı 02");
          userAyarlari.append("Kullanıcı ayarı 03");
          userAyarlari.append("Kullanıcı ayarı 04");
          userAyarlari.append("Kullanıcı ayarı 05");
          userAyarlari.append("Kullanıcı ayarı 06");
          userAyarlari.append("Kullanıcı ayarı 07");
          userAyarlari.append("Kullanıcı ayarı 08");
          userAyarlari.append("Kullanıcı ayarı 09");
          userAyarlari.append("Kullanıcı ayarı 10");
          userAyarlari.append("Kullanıcı ayarı 11");
          userAyarlari.append("Kullanıcı ayarı 12");
          userAyarlari.append("Kullanıcı ayarı 13");
          userAyarlari.append("Kullanıcı ayarı 14");
          userAyarlari.append("Kullanıcı ayarı 15");
          userAyarlari.append("Kullanıcı ayarı 16");
          userAyarlari.append("Kullanıcı ayarı 17");
          userAyarlari.append("Kullanıcı ayarı 18");
          userAyarlari.append("Kullanıcı ayarı 19");
      }
      void listeci::listeGuncelle()
      {
          listeElemanlar.setStringList(userAyarlari);
      }
      

      with these lines, I can successfully create a list and show on qml Listview, when I clicked on a button on qml side by calling

      frmlisteci.listeGuncelle()
      

      But when I do this procedure after a mount,( we can say refreshing the list) the code becoming slow, and waiting on this line:

      listeElemanlar.setStringList(userAyarlari);
      

      What can be the reason ?

      Edit : 1

      I just discover sth.

      On my project, I have 5 qml pages and I'm navigating between the pages with "Stackview".

      Here is the construction of stackview.

              // Sayfa bölmesi
              StackView {
                  id: stackci
                  initialItem: manuelSayfa
                  anchors.fill : sayfaBolmesi
      
                  pushEnter: Transition {
                      PropertyAnimation {
                          property: "opacity"
                          from: 0
                          to: 1
                          duration: 0
                      }
                  }
                  pushExit: Transition {
                      PropertyAnimation {
                          property: "opacity"
                          from: 1
                          to: 0
                          duration: 0
                      }
                  }
              }
      
              Component{
                  id:manuelSayfa
                  Manuel{}
              }
      
              Component{
                  id:otomatikSayfa
                  Otomatik{}
              }
      
              Component{
                  id:ayarlaraGirisSayfa
                  AyarlaraGiris{}
              }
      
              Component{
                  id:listelerSayfa
                  Liste{}
              }
      
              Component{
                  id:bilgiSayfa
                  Bilgi{}
              }
      

      And I'm navigating the pages with a signal from c++ like;

      on main.qml

          Connections{
              target: sayfaDegistirmeReferansi
              onSayfaDegistir:{
                  sayfaDegistir(s)
              }
          }
      
      .......
      
      function sayfaDegistir(sayfa)
          {
               if(sayfa == 100) stackci.push(manuelSayfa)
               .......
          }
      

      on main.cpp

          engine.rootContext()->setContextProperty("sayfaDegistirmeReferansi",&frmkeypad);
      

      My algorithm is like, when I send a signal to qml from c++, it first refresh the list, than open the page.

      The thing that I discovered is, when I refresh the list with MouseArea ( also same with signal from c++), it doesnt make a delay on refreshing the list.

      The difference is, I dont reload the page, only reloading the list....

      So what can be the problem ????

      Edit : 2

      I solved the problem.

      It is caused by stackview. I had used push method for changing the page.

      When I changed push method by replace, everything started to work well.....

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @bladekel said in qml QListview updating slow by c++:

      this procedure after a mount

      What's a mount?

      waiting on this line:
      listeElemanlar.setStringList(userAyarlari);

      This is probably due to the model having to reset itself completely. can you edit it instead?
      Also to test the speed with C++ and QML interactions use the release build, the debug becomes pretty heavy

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      B 1 Reply Last reply
      1
      • VRoninV VRonin

        @bladekel said in qml QListview updating slow by c++:

        this procedure after a mount

        What's a mount?

        waiting on this line:
        listeElemanlar.setStringList(userAyarlari);

        This is probably due to the model having to reset itself completely. can you edit it instead?
        Also to test the speed with C++ and QML interactions use the release build, the debug becomes pretty heavy

        B Offline
        B Offline
        bladekel
        wrote on last edited by
        #3

        @VRonin
        amount is not so much. It increase by every call such as on 10th 1sec waiting, on 20th 2sec waiting ... and so on....

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bladekel
          wrote on last edited by bladekel
          #4

          I discovered sth and edit my first post....

          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