Uploaded image for project: 'Qt Design Studio'
  1. Qt Design Studio
  2. QDS-11776

Implement ListView delegate

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • P2: Important
    • None
    • QDS 4.4.1
    • Collection Editor
    • None

    Description

      If a model is assigned to a ListView element, it should work as following

      1. The user has a ListView component already in the screen, or it is dragged out of library. He/she sees the content in the Model Editor
      2. Another Model is assigned to the ListView
      3. ListView gets the content from the model

      QML Example of the delegate which would be the end result

      import QtQuick 6.5import QtQuick.Controls 6.5import ModelEditor_2import QtQuick3D 6.5
      Rectangle {    id: rectangle    width: Constants.width    height: Constants.height
        
          ListView {        id: listView        x: 176        y: 284        width: 658        height: 119        spacing: 1        keyNavigationWraps: false        orientation: ListView.Vertical        model: ListModel {            ListElement {                isbn: ""                title: "Sayings of the Century"                price: 8.95                category: "reference"                author: "Nigel Rees"            }
                  ListElement {                isbn: ""                title: "Sword of Honor"                price: 12.99                category: "fiction"                author: "Evelyn Waugh"            }
                  ListElement {                isbn: "0-553-21311-3"                title: "Moby Dick"                price: 8.99                category: "fiction"                author: "Herman Melville"            }
                  ListElement {                isbn: "0-395-19395-8"                title: "The Lord of the Rings"                price: 22.99                category: "fiction"                author: "J.R.R. Tolkien"            }        }        delegate: Item {            x: 5            width: 150            height: 20            anchors.leftMargin: 0            Row {                id: row1                spacing: 30
                      Column {                    id: col1                    spacing: 20                    width: 100                    Text {                        text: author                        anchors.left: parent.left                        anchors.leftMargin: 0                        horizontalAlignment: Text.AlignLeft                        font.bold: true                    }                }                Column {                    id: col2                    spacing: 20                    width: 70                    Text {                        text: category                        anchors.left: parent.left                        anchors.leftMargin: 0                        horizontalAlignment: Text.AlignLeft                        font.bold: true                    }                }                Column {                    id: col3                    spacing: 20                    width: 50                    Text {                        text: price                        anchors.left: parent.left                        anchors.leftMargin: 0                        horizontalAlignment: Text.AlignLeft                        font.bold: true                    }                }                Column {                    id: col4                    spacing: 20                    width: 200                    Text {                        text: title                        anchors.left: parent.left                        anchors.leftMargin: 0                        font.bold: true                    }                }                Column {                    id: col5                    spacing: 20                    width: 100                    Text {                        text: isbn                        anchors.left: parent.left                        anchors.leftMargin: 0                        horizontalAlignment: Text.AlignLeft                        font.bold: true                    }                }            }        }    }}
       

      Attachments

        1. Screen01.ui.qml
          4 kB
        2. ListViewDraggedFromComponentLib.png
          ListViewDraggedFromComponentLib.png
          156 kB
        3. DelegateAssigned.png
          DelegateAssigned.png
          253 kB
        4. AssignTheModel.png
          AssignTheModel.png
          195 kB
        For Gerrit Dashboard: QDS-11776
        # Subject Branch Project Status CR V

        Activity

          People

            ali.kianian Ali Kianian
            hpaulaha Heikki Paulaharju
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes