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

modelData and ListView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 432 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    I have this ListView{} element and inside of it there is Component with a title property. For that title they have modelData.label set:

    ListView
    {
     ...
      Banner
      {
        title: modelData.label
      }
    }
    

    Can I assume that modelData is reffering to the ListView's model property? When I right click the modelData.label and select: "Follow symbol under cursor" it takes me nowhere. The actual model property for the ListView is being set to some value in the business logic.

    I guess what I am trying to ask is, if I create a ListView can I refer to it as modelData or is it a bad idea for me to assume that this modelData belongs to it's parent ListView?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Leonardo
      wrote on last edited by
      #2

      It depends on your model. From:

      https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html

      Models that do not have named roles will have the data provided via the modelData role. The modelData role is also provided for models that have only one role. In this case the modelData role contains the same data as the named role.

      If your model has roles, you could use just the role name, "label", or "model.label" to avoid ambiguity.

      C 1 Reply Last reply
      0
      • L Leonardo

        It depends on your model. From:

        https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html

        Models that do not have named roles will have the data provided via the modelData role. The modelData role is also provided for models that have only one role. In this case the modelData role contains the same data as the named role.

        If your model has roles, you could use just the role name, "label", or "model.label" to avoid ambiguity.

        C Offline
        C Offline
        Circuits
        wrote on last edited by
        #3

        @Leonardo Okay well this particular ListView has this model:

        model: presentationManager.settingsPresenter.propertiesForDevice
        

        I checked and propertiesForDevice() is defined as:

        QList<QObject*> propertiesDevice();
        
        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