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 delegate ListView
Forum Updated to NodeBB v4.3 + New Features

Listview delegate ListView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
11 Posts 3 Posters 1.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #2

    @jsulm maybe you can help me

    jsulmJ 1 Reply Last reply
    0
    • ? A Former User

      @jsulm maybe you can help me

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @NullByte No, I'm not a QML expert

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? A Former User

        How to use listview inside list view ? It's does not work. I don't see Text value in listview.

            ListView {
            
                    id: fixtureList
            
                    width: parent.width
            
                    height: parent.height - (header.height + tabBar.height) * dp
            
                    anchors.top: header.bottom
            
                    anchors.left: parent.left
            
                    focus: true
            
                    clip: true
            
                    model: ListModel{}
            
                    delegate: ListView {
            
                        id: dataList
            
                        model: detail
            
                        delegate: Rectangle {
            
                            color: "#ffffff"
            
                            Text {
            
                                id: startHours
            
                                text: qsTr("Hmmm")
            
                                anchors.centerIn: parent
            
                                color: "black"
            
                            }
            
                        }
            
            
            
                        Component.onCompleted: {
            
                            console.log(model.date)
            
                        }
            
            
            
                    }
            
            
            
                    section {
            
                        property: "name"
            
                        criteria: ViewSection.FullString
            
                        delegate: Rectangle {
            
                            color: "#d2d4c7"
            
                            width: parent.width
            
                            height: 50 * dp
            
            
            
                            Text {
            
                                text: section
            
                                anchors.left: parent.left
            
                                anchors.leftMargin: 40
            
                                anchors.top: parent.top
            
                                anchors.topMargin: 10
            
                                font.pixelSize: 17
            
                                font.family: fontRegular.name
            
            
            
                            }
            
                        }
            
            
            
                    }
            
                }
        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #4

        @NullByte your ListView delegate has no height and no width, give it some
        also your original ListModel is empty, that doesn't help either.


        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.

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

          @NullByte your ListView delegate has no height and no width, give it some
          also your original ListModel is empty, that doesn't help either.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #5

          @J-Hilk

          My listview code and append model JS function. I set width and height but I see only first listview section. I have no idea how to do it

              ListView {
                  id: fixtureList
                  width: parent.width
                  height: parent.height - (header.height + tabBar.height) * dp
                  anchors.top: header.bottom
                  anchors.left: parent.left
                  focus: true
                  clip: true
                  model: ListModel{}
                  delegate: ListView {
                      id: dataList
                      width: fixtureList.width
                      height: children.height
                      model: detail
                      delegate: Rectangle {
                          width: parent.width
                          height: 100 * dp
                          color: "#ffffff"
                          Text {
                              id: startDate
                              text: date
                              anchors.centerIn: parent
                              color: "black"
          
                              Component.onCompleted: {
                                  console.log(date)
                              }
                          }
                      }
                  }
          
                  section {
                      property: "name"
                      criteria: ViewSection.FullString
                      delegate: Rectangle {
                          color: "#d2d4c7"
                          width: parent.width
                          height: 50 * dp
          
                          Text {
                              text: section
                              anchors.left: parent.left
                              anchors.leftMargin: 40
                              anchors.top: parent.top
                              anchors.topMargin: 10
                              font.pixelSize: 17
                              font.family: fontRegular.name
          
                          }
                      }
          
                  }
              }
          
          
              function setData() {
                  var matchData
                  for(var i = 0; i < fixtureData.length; i++) {
                      fixtureList.model.append({id: fixtureData[i].id, name: fixtureData[i].name, image: fixtureData[i].category.image})
                      for(var k = 0; k < fixtureData[i].matchdata.length; k++) {
                          if(fixtureData[i].matchdata[k] !== undefined || fixtureData[i].matchdata[k] !== null) {
                              fixtureList.model.append({detail: fixtureData[i].matchdata[k], properties: fixtureData[i].matchdata[k].properties})
                          }
                      }
                  }
              }
          
          J.HilkJ 1 Reply Last reply
          0
          • ? A Former User

            @J-Hilk

            My listview code and append model JS function. I set width and height but I see only first listview section. I have no idea how to do it

                ListView {
                    id: fixtureList
                    width: parent.width
                    height: parent.height - (header.height + tabBar.height) * dp
                    anchors.top: header.bottom
                    anchors.left: parent.left
                    focus: true
                    clip: true
                    model: ListModel{}
                    delegate: ListView {
                        id: dataList
                        width: fixtureList.width
                        height: children.height
                        model: detail
                        delegate: Rectangle {
                            width: parent.width
                            height: 100 * dp
                            color: "#ffffff"
                            Text {
                                id: startDate
                                text: date
                                anchors.centerIn: parent
                                color: "black"
            
                                Component.onCompleted: {
                                    console.log(date)
                                }
                            }
                        }
                    }
            
                    section {
                        property: "name"
                        criteria: ViewSection.FullString
                        delegate: Rectangle {
                            color: "#d2d4c7"
                            width: parent.width
                            height: 50 * dp
            
                            Text {
                                text: section
                                anchors.left: parent.left
                                anchors.leftMargin: 40
                                anchors.top: parent.top
                                anchors.topMargin: 10
                                font.pixelSize: 17
                                font.family: fontRegular.name
            
                            }
                        }
            
                    }
                }
            
            
                function setData() {
                    var matchData
                    for(var i = 0; i < fixtureData.length; i++) {
                        fixtureList.model.append({id: fixtureData[i].id, name: fixtureData[i].name, image: fixtureData[i].category.image})
                        for(var k = 0; k < fixtureData[i].matchdata.length; k++) {
                            if(fixtureData[i].matchdata[k] !== undefined || fixtureData[i].matchdata[k] !== null) {
                                fixtureList.model.append({detail: fixtureData[i].matchdata[k], properties: fixtureData[i].matchdata[k].properties})
                            }
                        }
                    }
                }
            
            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by J.Hilk
            #6

            @NullByte
            I still can't work with that 🤷‍♂️

            here's a minimal working compile-able example:

            Window
            {
                visible: true
                width: 640
                height: 480
                title: qsTr("Hello World")
                color: "white"
                id: win
            
                ListView {
                    id: fixtureList
                    anchors.fill: parent
                    focus: true
                    clip: true
                    model: 20
            
                    delegate: ListView {
                        id: dataList
                        width: fixtureList.width * 2 / 3 // Allow right 1/3 to scroll main ListView
                        height: fixtureList.height / 5  //limit to 5 Entrys(dataLists) per mainview(fixtureList)
                        model: 10
                        clip: true
                        property int id: index
            
                        delegate: Rectangle {
                            width: parent.width
                            height: 100
                            color: dataList.id % 2 ? "darkred" : "steelblue"
                            Text {
                                id: startDate
                                text: "SubList %1 entry %2".arg(dataList.id).arg(index)
                                anchors.centerIn: parent
                                color: "black"
                            }
                        }
                    }
                }
            }
            

            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.

            ? 2 Replies Last reply
            1
            • J.HilkJ J.Hilk

              @NullByte
              I still can't work with that 🤷‍♂️

              here's a minimal working compile-able example:

              Window
              {
                  visible: true
                  width: 640
                  height: 480
                  title: qsTr("Hello World")
                  color: "white"
                  id: win
              
                  ListView {
                      id: fixtureList
                      anchors.fill: parent
                      focus: true
                      clip: true
                      model: 20
              
                      delegate: ListView {
                          id: dataList
                          width: fixtureList.width * 2 / 3 // Allow right 1/3 to scroll main ListView
                          height: fixtureList.height / 5  //limit to 5 Entrys(dataLists) per mainview(fixtureList)
                          model: 10
                          clip: true
                          property int id: index
              
                          delegate: Rectangle {
                              width: parent.width
                              height: 100
                              color: dataList.id % 2 ? "darkred" : "steelblue"
                              Text {
                                  id: startDate
                                  text: "SubList %1 entry %2".arg(dataList.id).arg(index)
                                  anchors.centerIn: parent
                                  color: "black"
                              }
                          }
                      }
                  }
              }
              
              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

              @J-Hilk

              Thanks so much.
              It's not work. I see two listview section one is empty another one is true. And second listview (dataList) delagete is not running.

                  ListView {
                      id: fixtureList
                      width: parent.width
                      height: (parent.height - (header.height + tabBar.height * dp) * dp)
                      anchors.top: header.bottom
                      anchors.left: parent.left
                      focus: true
                      clip: true
                      model: ListModel{}
                      delegate: ListView {
                          id: dataList
                          width: fixtureList.width * 2 / 3 // Allow right 1/3 to scroll main ListView
                          height: fixtureList.height / 5  //limit to 5 Entrys(dataLists) per mainview(fixtureList)
                          model: detail
                          clip: true
                          property int id: index
              
                          delegate: Rectangle {
                              width: parent.width
                              height: 100 * dp
                              color: dataList.id % 2 ? "darkred" : "steelblue"
                              Text { // not showing.
                                  id: startDate
                                  text: "SubList %1 entry %2".arg(dataList.id).arg(index)
                                  anchors.centerIn: parent
                                  color: "black"
              
                                  Component.onCompleted: {
                                      console.log(id) // Cannot print.
                                  }
                              }
                          }
                      }
              
                      section {
                          property: "name"
                          criteria: ViewSection.FullString
                          delegate: Rectangle {
                              color: "#d2d4c7"
                              width: parent.width
                              height: 50 * dp
              
                              Text {
                                  text: section
                                  anchors.left: parent.left
                                  anchors.leftMargin: 40
                                  anchors.top: parent.top
                                  anchors.topMargin: 10
                                  font.pixelSize: 17 * dp
                                  font.family: fontRegular.name
              
                              }
                          }
              
                      }
                  }
              
              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #8

                dataList delegate is not running/work

                        delegate: Rectangle {
                            width: parent.width
                            height: 100 * dp
                            color: dataList.id % 2 ? "red" : "blue"
                            Text { // not showing.
                                id: startDate
                                text: "SubList %1 entry %2".arg(dataList.id).arg(index)
                                anchors.centerIn: parent
                                color: "black"
                
                                Component.onCompleted: {
                                    console.log("I'm here ") // not print
                                }
                            }
                
                            Component.onCompleted: {
                                console.log("I'm here 1") // not print
                            }
                        }
                
                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #9

                  @SGaist have any idea ?

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

                    @NullByte
                    I still can't work with that 🤷‍♂️

                    here's a minimal working compile-able example:

                    Window
                    {
                        visible: true
                        width: 640
                        height: 480
                        title: qsTr("Hello World")
                        color: "white"
                        id: win
                    
                        ListView {
                            id: fixtureList
                            anchors.fill: parent
                            focus: true
                            clip: true
                            model: 20
                    
                            delegate: ListView {
                                id: dataList
                                width: fixtureList.width * 2 / 3 // Allow right 1/3 to scroll main ListView
                                height: fixtureList.height / 5  //limit to 5 Entrys(dataLists) per mainview(fixtureList)
                                model: 10
                                clip: true
                                property int id: index
                    
                                delegate: Rectangle {
                                    width: parent.width
                                    height: 100
                                    color: dataList.id % 2 ? "darkred" : "steelblue"
                                    Text {
                                        id: startDate
                                        text: "SubList %1 entry %2".arg(dataList.id).arg(index)
                                        anchors.centerIn: parent
                                        color: "black"
                                    }
                                }
                            }
                        }
                    }
                    
                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #10

                    @J-Hilk said in Listview delegate ListView:

                    @NullByte
                    I still can't work with that 🤷‍♂️

                    here's a minimal working compile-able example:

                    Window
                    {
                        visible: true
                        width: 640
                        height: 480
                        title: qsTr("Hello World")
                        color: "white"
                        id: win
                    
                        ListView {
                            id: fixtureList
                            anchors.fill: parent
                            focus: true
                            clip: true
                            model: 20
                    
                            delegate: ListView {
                                id: dataList
                                width: fixtureList.width * 2 / 3 // Allow right 1/3 to scroll main ListView
                                height: fixtureList.height / 5  //limit to 5 Entrys(dataLists) per mainview(fixtureList)
                                model: 10
                                clip: true
                                property int id: index
                    
                                delegate: Rectangle {
                                    width: parent.width
                                    height: 100
                                    color: dataList.id % 2 ? "darkred" : "steelblue"
                                    Text {
                                        id: startDate
                                        text: "SubList %1 entry %2".arg(dataList.id).arg(index)
                                        anchors.centerIn: parent
                                        color: "black"
                                    }
                                }
                            }
                        }
                    }
                    

                    It's solved. Thanks for help.

                    Problem is my model is to be wrong.

                    J.HilkJ 1 Reply Last reply
                    3
                    • ? A Former User

                      @J-Hilk said in Listview delegate ListView:

                      @NullByte
                      I still can't work with that 🤷‍♂️

                      here's a minimal working compile-able example:

                      Window
                      {
                          visible: true
                          width: 640
                          height: 480
                          title: qsTr("Hello World")
                          color: "white"
                          id: win
                      
                          ListView {
                              id: fixtureList
                              anchors.fill: parent
                              focus: true
                              clip: true
                              model: 20
                      
                              delegate: ListView {
                                  id: dataList
                                  width: fixtureList.width * 2 / 3 // Allow right 1/3 to scroll main ListView
                                  height: fixtureList.height / 5  //limit to 5 Entrys(dataLists) per mainview(fixtureList)
                                  model: 10
                                  clip: true
                                  property int id: index
                      
                                  delegate: Rectangle {
                                      width: parent.width
                                      height: 100
                                      color: dataList.id % 2 ? "darkred" : "steelblue"
                                      Text {
                                          id: startDate
                                          text: "SubList %1 entry %2".arg(dataList.id).arg(index)
                                          anchors.centerIn: parent
                                          color: "black"
                                      }
                                  }
                              }
                          }
                      }
                      

                      It's solved. Thanks for help.

                      Problem is my model is to be wrong.

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

                      @NullByte Great that you managed to find the issue 😁,
                      good luck!


                      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.

                      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