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. Access Q_PROPERTY from ListModel
Qt 6.11 is out! See what's new in the release blog

Access Q_PROPERTY from ListModel

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 553 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.
  • W Offline
    W Offline
    Wowalive
    wrote on last edited by
    #1

    Hi,

    I'm struggling with accessing a Q_PROPERTY within a ListElement in a ListModel from QML:

                model: ListModel {
                    id:modelApps
                    ListElement {
                        itemTitle: qsTr("TEAM")
                        itemSource: "qrc:/pages/Team.qml"
                        itemImage: "qrc:/images/Icons/team.png"
                        itemCount: _mainViewModel.rowCount
                    }
                }
    

    I always get following error message: ListElement: cannot use script for property value

    Is there a proper way to achieve my intend?

    Best regards,
    wowalive

    sierdzioS 1 Reply Last reply
    0
    • W Wowalive

      Hi,

      I'm struggling with accessing a Q_PROPERTY within a ListElement in a ListModel from QML:

                  model: ListModel {
                      id:modelApps
                      ListElement {
                          itemTitle: qsTr("TEAM")
                          itemSource: "qrc:/pages/Team.qml"
                          itemImage: "qrc:/images/Icons/team.png"
                          itemCount: _mainViewModel.rowCount
                      }
                  }
      

      I always get following error message: ListElement: cannot use script for property value

      Is there a proper way to achieve my intend?

      Best regards,
      wowalive

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Wowalive said in Access Q_PROPERTY from ListModel:

      Is there a proper way to achieve my intend?

      Yes: don't use ListElements. Use other model types (like QObjectList model, or a full QAbstractItemModel) - more info in ther docs: https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html#models

      (Z(:^

      1 Reply Last reply
      4

      • Login

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