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 loaded with Loader does not have modelData, index and ListView attached properties
Forum Updated to NodeBB v4.3 + New Features

ListView Delegate loaded with Loader does not have modelData, index and ListView attached properties

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 558 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.
  • F Offline
    F Offline
    feldifux
    wrote on last edited by
    #1

    Hi,
    I'm trying to load a delegate in a Loader based on the type of its model:

    @import QtQuick 2.0

    ListView {
    model: [
    {"type":"header", "title":"Header 1"},
    {"type":"content", "itemContent":"List Item 1"}
    ]
    delegate: Loader {
    sourceComponent: modelData.type === "header" ? headerComponent : itemComponent
    }

    Component {
    id: headerComponent
    Text {
    // NOTE: modelData is undefined here!
    text: modelData.title
    }
    }

    Component {
    id: itemComponent
    Text {
    // NOTE: modelData is undefined here!
    text: modelData.itemContent
    // this also does not work
    font.bold: ListView.isCurrentItem
    // index is also not known...
    }
    }

    }

    @

    Any hints how to select a delegate based on the modelData content?

    Cheers,
    Chris

    Founder of Felgo SDK - http://felgo.com/qt

    Felgo simplifies

    • Mobile App Dev with Qt esp. iOS & Android
    • Game Development with Qt

    What others say

    Felgo scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

    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