This forum has been archived. All content is frozen. Please use KDE Discuss instead.

QML Model with custom property

Tags: None
(comma "," separated)
Daniel_Boff
Registered Member
Posts
82
Karma
0

QML Model with custom property

Mon Sep 09, 2013 6:49 pm
Hi guys!

I'm just programming a small qml plasmoid. In my plasmoid I want to use a XmlListModel inside of another XmlListModel. The query of the first Model in dependent on a variable which is fetched by the first one.
Here the code:

Code: Select all
  Component {
    id: matchDelegate
       
    Item {
      width: 300; height: 50             
       Rectangle {
     width: 300; height: 40
     Column {
   
       Text {
         text: match_id
       }
    
       Rectangle {
         width: 300; height: 15 
         ListView {
      width: 300; height: 15 
      orientation: ListView.Horizontal
      model: HeroModel {
        //match_id: "304723270"  // WORKING
                  match_id: match_id        //!! NOT WORKING!!!
      }
      
      delegate: HeroDelegate {}
      
      highlight: highlight
      highlightFollowsCurrentItem: true
      focus: true
         }
       }
       Text {
         text: "|"
       }
   }
      }
    }
  }


The variable, which is fetched by the first model is match_id and displaying it with
Code: Select all
       Text {
         text: match_id
       }

works as intendet. However, I somehow cannot assign the property match_id of the HeroModel with this value,
Code: Select all
      model: HeroModel {
        //match_id: "304723270"  // WORKING
                  match_id: match_id        //!! NOT WORKING!!!
      }


The HeroModel is defined as follows:
Code: Select all
  import QtQuick 1.0
  XmlListModel {
    id: heroModel
    property string match_id
   /* ... */
  }


Why is
Code: Select all
      model: HeroModel {
                  match_id: match_id
      }

not working, and how can I fix this?

cheers, Daniel
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: QML Model with custom property

Tue Sep 10, 2013 9:46 am
I would recommend posting this question to the plasma-devel@kde.org mailing list, as they will likely know the solution.
Please mention the version of KDE/Qt you are targeting.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], Yahoo [Bot]