[SailfishDevel] Page Status code

Chris Walker cdw_nokiaqt at the-walker-household.co.uk
Thu Feb 13 12:05:42 UTC 2014


On Thu, 13 Feb 2014 00:19:42 +0100
Thomas Perl <th.perl at gmail.com> wrote:

> On 2014-02-12 20:36, Chris Walker wrote:
> > In the past (Harmattan code), I would have done this sort of
> > stuff :-
> >
> > onStatusChanged: {
> >          if (status==PageStatus.Activating) {
> >
> > but there is no 'onStatusChanged' option now. So what do I use now?
> >
> > I've looked here -
> > https://sailfishos.org/sailfish-silica/qml-sailfishsilica-page.html
> > but it doesn't mention that status directly.
> 
> In QML, every property automatically has a on[Property]Changed
> signal, and those signals are not documented, because the language
> itself defines that such signals always exist for each property and
> therefore do not need to be documented explicitly. The documented
> "status" property will - when changed - cause the "onStatusChanged"
> handler to be called.
> 
> From 
> http://qt-project.org/doc/qt-5.0/qtqml/qtqml-syntax-objectattributes.html#property-change-signal-handlers:
> 
> "Signal handlers for property change signal take the syntax form 
> /on<Property>Changed/ where /<Property>/ is the name of the property, 
> with the first letter capitalized. For example, although the
> TextInput
> <http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-textinput.html>
> type documentation does not document a textChanged signal, this
> signal is implicitly available through the fact that TextInput
> <http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-textinput.html>
> has a text
> <http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-textinput.html#text-prop>
> property and so it is possible to write an onTextChanged signal
> handler to be called whenever this property changes [...]"
> 
> So the code as written above (onStatusChanged) should in fact work
> as-is.
> 
> HTH :)

I'll add all that to "yet more stuff to learn" :-)

Many thanks.


More information about the Devel mailing list