Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Swipeview: how to render faster when many items in each pages
Qt 6.12 LTS is out! See what's new in the release blog

Swipeview: how to render faster when many items in each pages

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 715 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.
  • Y Offline
    Y Offline
    ynatynat
    wrote on last edited by
    #1

    I tried to use Loader{} like help page
    But it is still slow.
    How to swipe rendering be faster?

    Test.qml

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import QtQuick.Layouts 1.15
    
    Page {
        ListModel{
            id:page_items
            ListElement{kandoitem:"TestChild.qml"}
            ListElement{kandoitem:"TestChild.qml"}
            ListElement{kandoitem:"TestChild.qml"}
            ListElement{kandoitem:"TestChild.qml"}
            ListElement{kandoitem:"TestChild.qml"}
            ListElement{kandoitem:"TestChild.qml"}
        }
        footer:Button{text:"close"
            onClicked:{
                stackView.pop(StackView.Immediate)
            }
        }
        TabBar {
            id: bar
            width: parent.width
            currentIndex:swipe.currentIndex
            TabButton {
                text: qsTr("A")
            }
            TabButton {
                text: qsTr("B")
            }
            TabButton {
                text: qsTr("C")
            }
            TabButton {
                text: qsTr("D")
            }
            TabButton {
                text: qsTr("E")
            }
            TabButton {
                text: qsTr("F")
            }
            TabButton {
                text: qsTr("G")
            }
    
        }
        SwipeView {
            id:swipe
    
            width: parent.width
            height:parent.height-bar.height-footer.height
            anchors.top: bar.bottom
            currentIndex: bar.currentIndex
            Repeater{
                model:page_items
                Loader{
    
                    id:pageLoader
                    active:SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem
                    source:kandoitem
                    asynchronous: false
    
                }
            }
        }
    }
    
    
    

    TestChild.qml

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import QtQuick.Layouts 1.15
    
    Item {
        anchors.centerIn: parent
        width:parent.width
        height:parent.height-80
        Flow{
            anchors.fill: parent
            Repeater{
                model:100
                Button{text:index}
            }
        }
    }
    
    
    GrecKoG 1 Reply Last reply
    0
    • Y ynatynat

      I tried to use Loader{} like help page
      But it is still slow.
      How to swipe rendering be faster?

      Test.qml

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Layouts 1.15
      
      Page {
          ListModel{
              id:page_items
              ListElement{kandoitem:"TestChild.qml"}
              ListElement{kandoitem:"TestChild.qml"}
              ListElement{kandoitem:"TestChild.qml"}
              ListElement{kandoitem:"TestChild.qml"}
              ListElement{kandoitem:"TestChild.qml"}
              ListElement{kandoitem:"TestChild.qml"}
          }
          footer:Button{text:"close"
              onClicked:{
                  stackView.pop(StackView.Immediate)
              }
          }
          TabBar {
              id: bar
              width: parent.width
              currentIndex:swipe.currentIndex
              TabButton {
                  text: qsTr("A")
              }
              TabButton {
                  text: qsTr("B")
              }
              TabButton {
                  text: qsTr("C")
              }
              TabButton {
                  text: qsTr("D")
              }
              TabButton {
                  text: qsTr("E")
              }
              TabButton {
                  text: qsTr("F")
              }
              TabButton {
                  text: qsTr("G")
              }
      
          }
          SwipeView {
              id:swipe
      
              width: parent.width
              height:parent.height-bar.height-footer.height
              anchors.top: bar.bottom
              currentIndex: bar.currentIndex
              Repeater{
                  model:page_items
                  Loader{
      
                      id:pageLoader
                      active:SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem
                      source:kandoitem
                      asynchronous: false
      
                  }
              }
          }
      }
      
      
      

      TestChild.qml

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Layouts 1.15
      
      Item {
          anchors.centerIn: parent
          width:parent.width
          height:parent.height-80
          Flow{
              anchors.fill: parent
              Repeater{
                  model:100
                  Button{text:index}
              }
          }
      }
      
      
      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      @ynatynat Try a horizontal ListView with reuseItems enabled.

      J.HilkJ 1 Reply Last reply
      0
      • Y Offline
        Y Offline
        ynatynat
        wrote on last edited by
        #3

        I tried GridView, which is loaded array(QVector) of c++ model.
        But it is still slow.

            GridView{
                id:grid
                anchors.fill: parent
                model:30
                cellWidth:parent.width/3
                cellHeight:50
        
        
                delegate:Component{
        
                    ValueBox{
                        name:index
                        min:0;max:100;
                        array_id:index;unit:"unit"
                        array:cppModel.array;
                        width: grid.cellWidth
                    }
                }
        }
        

        ValueBox is original type, which has button, spinbox, label. Button open a panel.

        1 Reply Last reply
        0
        • GrecKoG GrecKo

          @ynatynat Try a horizontal ListView with reuseItems enabled.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @GrecKo said in Swipeview: how to render faster when many items in each pages:

          @ynatynat Try a horizontal ListView with reuseItems enabled.

          @ynatynat said

          alt text


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          Y 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @GrecKo said in Swipeview: how to render faster when many items in each pages:

            @ynatynat Try a horizontal ListView with reuseItems enabled.

            @ynatynat said

            alt text

            Y Offline
            Y Offline
            ynatynat
            wrote on last edited by ynatynat
            #5

            @GrecKo
            @J-Hilk
            sorry, I misunderstood.
            As Grecko said ListView with resuseItems is good to be faster.

            1 Reply Last reply
            1
            • Y ynatynat has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt
            • Unsolved