[SailfishDevel] Access elements in a SilicaListView header

Sylvain B. sthocs at hotmail.com
Mon Feb 16 23:43:02 UTC 2015


Thanks a lot!
I had tried with what is written in the example with no success:

SilicaListView {
    property alias searchField: headerItem

Gives me: Invalid alias reference. Unable to find id "headerItem"

But doing it your way works fine, thank you! (the example in the doc should be updated with your solution. Or did I miss something?)

----------------------------------------
> Date: Tue, 17 Feb 2015 01:01:13 +0500
> From: coderusinbox at gmail.com
> To: devel at lists.sailfishos.org
> Subject: Re: [SailfishDevel] Access elements in a SilicaListView header
>
> Hello, in this case you can do following:
>
> Page {
> SilicaListView {
> id: listView
> anchors.fill: parent
>
> PullDownMenu {
> MenuItem {
> text: qsTr("Update search field")
> onClicked: { listView.headerItem.text = "hi" }
> }
> }
>
> header : SearchField {
> id: searchField
> width: parent.width
> placeholderText: "Filter"
> }
> }
> }
>
> 17.02.2015 00:57, Sylvain B. пишет:
>> Hi,
>> I'd like to put a SearchField into the header of a SilicaListView, but I figured out that I can't access it from outside (I want to clear the text when the user refreshes the model).
>> The code below will trigger a "ReferenceError: searchField is not defined":
>>
>> Page {
>> SilicaListView {
>> anchors.fill: parent
>>
>> PullDownMenu {
>> MenuItem {
>> text: qsTr("Update search field")
>> onClicked: { searchField.text = "hi" }
>> }
>> }
>>
>> header : SearchField {
>> id: searchField
>> width: parent.width
>> placeholderText: "Filter"
>> }
>> }
>> }
>>
>> Any idea?
>> Thanks.
>>
>> _______________________________________________
>> SailfishOS.org Devel mailing list
>> To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org
>
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org
 		 	   		  


More information about the Devel mailing list