← Back to team overview

ubuntu-phone team mailing list archive

Re: Can't set value of Label inside

 

Michael is right, both issues can be found in code.

P.S. Sam, let me give you a little advice - try to write working QML code
by hand,
and only then use your tools for automatic generation!

BR,
Roman.


2014-07-23 15:47 GMT+04:00 Michael Zanetti <michael.zanetti@xxxxxxxxxxxxx>:

>
> 2 issues:
>
> a) By the time Component.onCompleted is called. the PopupUtils.open()
> hasn't
> been called yet. So the popover doesn't exist
>
> b) Even if you'd change the order, I don't think you can reach inside the
> Popover's context... You could open 10 of those popovers, which label
> should
> be addressed then?
>
>
> Solution: create a property somewhere (outside the Popover Component), like
> this:
>
> property string popoverLabelText
>
> inside the Popover's Label do:
>
> text: popoverLabelText
>
> Hope this helps
>
> On Wednesday 23 July 2014 12:38:15 Sam Bull wrote:
> > I'm trying to set the value of the label in the below code, but the
> > onCompleted code seems to be unable to reference the label inside the
> > Component, and the label seems unable to access any property outside the
> > Component, so I can't see any way to change the text value at runtime.
> > Any ideas?
> >
> >
> > AbstractButton {
> >     width: img_idm109614992.width
> >     height: img_idm109614992.height
> >     onClicked: PopupUtils.open(popover_idm109614992, img_idm109614992)
> >     Component.onCompleted: {
> >         var fak
> >         for (var i=0; i < fakojModel.count; ++i) {
> >             fak = fakojModel.get(i)
> >             if (fak.code == "LIN") {
> >                 img_idm109614992.source = path + fak.img
> >                 label_idm109614992.text = fak.text  // Reference error
> >             }
> >         }
> >     }
> >
> >     Image {
> >         id: img_idm109614992
> >     }
> >
> >     Component {
> >         id: popover_idm109614992
> >         Popover {
> >             Label {
> >                 id: label_idm109614992
> >             }
> >         }
> >     }
> > }
>
>
> --
> Mailing list: https://launchpad.net/~ubuntu-phone
> Post to     : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ubuntu-phone
> More help   : https://help.launchpad.net/ListHelp
>

References