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. ListView : Showing only initial few data
Forum Updated to NodeBB v4.3 + New Features

ListView : Showing only initial few data

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 2 Posters 1.5k 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.
  • Naveen_DN Offline
    Naveen_DN Offline
    Naveen_D
    wrote on last edited by Naveen_D
    #1

    Hi all

    I am using list view to show some information as a list but when i am setting the model it is showing the first 3 data of that list model.
    can anyone please tell me what mistake i have done. Here is the code

    import QtQuick 2.7
    import QtQuick.Layouts 1.3
    import QtQuick.Controls 2.1
    import QtQuick.Controls.Material 2.1
    import QtGraphicalEffects 1.0
    
    import "../common"
    
    Flickable {
        id: flickable
        property bool selectAccentColor: false
        contentHeight: root.implicitHeight
        property string name: "ContactsPage"
        property string title: qsTr("Contacts")
    
        Pane {
            id: root
            anchors.fill: parent
            ColumnLayout {
                anchors.right: parent.right
                anchors.left: parent.left
                LabelHeadline {
                    leftPadding: 10
                    text: qsTr("All Contacts")
                }
                HorizontalDivider{}
                RowLayout {
                    ListView {
                        id: listView
                        anchors.fill: parent
                        implicitHeight: root.height
                        focus: true
                        delegate: Item {
                            id: itemDelegate
                            width: parent.width
                            implicitHeight: 40
                            Row {
                                spacing: 0
                                leftPadding: 10
                                Rectangle {
                                    visible: selectAccentColor
                                    anchors.verticalCenter: parent.verticalCenter
                                    implicitHeight: 32
                                    implicitWidth: 48
                                    color: primaryColor
                                }
                                Rectangle {
                                    anchors.verticalCenter: parent.verticalCenter
                                    implicitHeight: 32
                                    implicitWidth: 32
                                    color: primaryColor
                                }
                                LabelBody {
                                    leftPadding: 10
                                    anchors.verticalCenter: parent.verticalCenter
                                    text: model.title
                                }
                                LabelBody {
                                    leftPadding: 30
                                    anchors.verticalCenter: parent.verticalCenter
                                    text: model.num
                                }
                            } // end Row
                        }// delegateItem
                        model: ListModel {
                            ListElement { title: qsTr("Anoop"); num: "9556482322" }
                            ListElement { title: qsTr("Arohi"); num: "9556482322" }
                            ListElement { title: qsTr("Akash"); num: "9556482322" }
                            ListElement { title: qsTr("Bipin"); num: "9556482322" }
                            ListElement { title: qsTr("Bhoomi"); num: "9556482322" }
                            ListElement { title: qsTr("Chaitanya"); num: "9556482322" }
                            ListElement { title: qsTr("Chinmayee"); num: "9556482322" }
                            ListElement { title: qsTr("Chaya "); num: "9556482322" }
                            ListElement { title: qsTr("Daksh"); num: "9556482322" }
                            ListElement { title: qsTr("Devashish"); num: "9556482322" }
                            ListElement { title: qsTr("Daksha"); num: "9556482322" }
                            ListElement { title: qsTr("Guru"); num: "9556482322" }
                            ListElement { title: qsTr("Lahari"); num: "9556482322" }
                            ListElement { title: qsTr("Meghana"); num: "9556482322" }
                            ListElement { title: qsTr("Madhav"); num: "9556482322" }
                            ListElement { title: qsTr("Nilima"); num: "9556482322" }
                            ListElement { title: qsTr("Neehar"); num: "9556482322" }
                            ListElement { title: qsTr("Siddharth"); num: "9556482322" }
                            ListElement { title: qsTr("Satish"); num: "9556482322" }
                        }
                    }// end of list view
                }// RowLayout
            }// ColumnLayout
        }// Pane
        ScrollIndicator.vertical: ScrollIndicator { }
    
    }// end flickable
    

    Naveen_D

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by dheerendra
      #2

      This should help you to fix. It is the size issue all the way from Flickable to your listView.

      However we can do better as well. I have just corrected on what you have done.

      Flickable {
      id: flickable
      width: 300;height: 500

      Pane {
          id: root
          anchors.fill: parent
          ColumnLayout {
              anchors.fill: parent
              anchors.right: parent.right
              anchors.left: parent.left
              Label {
                  leftPadding: 10
                  text: qsTr("All Contacts")
              }
              HorizontalDivider{}
              RowLayout {
                  anchors.fill: parent
                  ListView {
                      id: listView
                      anchors.fill: parent
              RowLayout {
                  anchors.fill: parent
                  ListView {
                      id: listView
                      anchors.fill: parent
      

      }

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      Naveen_DN 1 Reply Last reply
      3
      • dheerendraD dheerendra

        This should help you to fix. It is the size issue all the way from Flickable to your listView.

        However we can do better as well. I have just corrected on what you have done.

        Flickable {
        id: flickable
        width: 300;height: 500

        Pane {
            id: root
            anchors.fill: parent
            ColumnLayout {
                anchors.fill: parent
                anchors.right: parent.right
                anchors.left: parent.left
                Label {
                    leftPadding: 10
                    text: qsTr("All Contacts")
                }
                HorizontalDivider{}
                RowLayout {
                    anchors.fill: parent
                    ListView {
                        id: listView
                        anchors.fill: parent
                RowLayout {
                    anchors.fill: parent
                    ListView {
                        id: listView
                        anchors.fill: parent
        

        }

        Naveen_DN Offline
        Naveen_DN Offline
        Naveen_D
        wrote on last edited by
        #3

        @dheerendra Thank you for the reply...but if i use height, i am not able to flick it.

        Naveen_D

        1 Reply Last reply
        1
        • Naveen_DN Offline
          Naveen_DN Offline
          Naveen_D
          wrote on last edited by
          #4

          Can anyone please guide me further in this matter
          Thanks

          Naveen_D

          1 Reply Last reply
          0
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Qt Champions 2022
            wrote on last edited by dheerendra
            #5

            Listview comes by default with flickable. Y r u placing listview in flickable again ?
            Check the following example.

            import QtQuick 2.7
            import QtQuick.Layouts 1.3
            import QtQuick.Controls 2.1
            import QtQuick.Controls.Material 2.1
            import QtGraphicalEffects 1.0

            Pane {
            id: root
            width: 300;height : 600
            property color primaryColor : "red"
            property bool selectAccentColor: false
            ColumnLayout {
            anchors.right: parent.right
            anchors.left: parent.left
            anchors.fill: parent
            Rectangle {
            id : txt
            width: root.width;height: 30;color :"blue"
            z : 10
            Text {
            id : txt1
            leftPadding: 10
            text: qsTr("All Contacts")
            }
            }
            ListView {
            id: listView
            anchors.top: txt.bottom
            width: root.width;height : root.height-100
            implicitHeight: root.height
            focus: true
            delegate: MyDelegate{}
            model: MyModel{}
            snapMode: ListView.SnapToItem
            z : 1
            }// end of list view
            }// ColumnLayout
            }// Pane

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            Naveen_DN 1 Reply Last reply
            3
            • dheerendraD dheerendra

              Listview comes by default with flickable. Y r u placing listview in flickable again ?
              Check the following example.

              import QtQuick 2.7
              import QtQuick.Layouts 1.3
              import QtQuick.Controls 2.1
              import QtQuick.Controls.Material 2.1
              import QtGraphicalEffects 1.0

              Pane {
              id: root
              width: 300;height : 600
              property color primaryColor : "red"
              property bool selectAccentColor: false
              ColumnLayout {
              anchors.right: parent.right
              anchors.left: parent.left
              anchors.fill: parent
              Rectangle {
              id : txt
              width: root.width;height: 30;color :"blue"
              z : 10
              Text {
              id : txt1
              leftPadding: 10
              text: qsTr("All Contacts")
              }
              }
              ListView {
              id: listView
              anchors.top: txt.bottom
              width: root.width;height : root.height-100
              implicitHeight: root.height
              focus: true
              delegate: MyDelegate{}
              model: MyModel{}
              snapMode: ListView.SnapToItem
              z : 1
              }// end of list view
              }// ColumnLayout
              }// Pane

              Naveen_DN Offline
              Naveen_DN Offline
              Naveen_D
              wrote on last edited by
              #6

              @dheerendra Thanks... I got that :)

              Naveen_D

              1 Reply Last reply
              2
              • dheerendraD Offline
                dheerendraD Offline
                dheerendra
                Qt Champions 2022
                wrote on last edited by
                #7

                Cool. Move the issue to "SOLVED" state. It helps others as well.

                Dheerendra
                @Community Service
                Certified Qt Specialist
                http://www.pthinks.com

                Naveen_DN 1 Reply Last reply
                2
                • dheerendraD dheerendra

                  Cool. Move the issue to "SOLVED" state. It helps others as well.

                  Naveen_DN Offline
                  Naveen_DN Offline
                  Naveen_D
                  wrote on last edited by
                  #8

                  @dheerendra Ya sure....:-)

                  Naveen_D

                  1 Reply Last reply
                  1

                  • Login

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