#1  
Old 12-01-2011, 08:14 AM
qazwsx qazwsx is offline
Junior Member
 
Join Date: Dec 2011
Posts: 1
Default attached properties

hi all,

i couldnt understand the attached properties in qml. can anyone help me with it?

Code:
 Component {
     id: myDelegate
     Text {
         text: "Hello"
         color: ListView.isCurrentItem ? "red" : "blue"
     }
 } 



ListView {
     delegate: myDelegate
 }

how do delegates work?
what exactly is attached property and how do attached properties work here?
Reply With Quote
  #2  
Old 12-01-2011, 09:59 AM
nicolai's Avatar
nicolai nicolai is offline
Senior Member
 
Join Date: Feb 2010
Posts: 124
Thanked: 134 times
Default Re: attached properties

The component "myDelegate" will be created/instantiated by
the ListView for every visible item in the model.

Sometimes you need some information for your delegate component
which is not accessible in you qml source. isCurrentItem for example
is a property of your ListView-items, which indicates if this item is
the currently selected one. But the only one who is aware about
the isCurrentItem property is your ListView, when it actually created
the ListView-items. So the listview attaches this propery on your delegate
component when it creates this component for its ListView-item.
Reply With Quote

The Following 2 Users Say Thank You to nicolai For This Useful Post:
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nautilus crash when I want to view properties in a file.? robotno Netbook 5 02-05-2011 12:21 PM


All times are GMT. The time now is 10:18 PM.