[Interest] Disabling signal connections for an item and its children
Elvis Stansvik
elvstone at gmail.com
Sat May 7 12:02:06 CEST 2016
2016-05-07 11:32 GMT+02:00 Elvis Stansvik <elvstone at gmail.com>:
> Hi all,
>
> In a fullscreen page-based embedded QML app (HMI), I find myself often
> wanting to disable all signal connections when the page is not active
> (on top of stack).
>
> I found this 5 year old bug:
>
> https://bugreports.qt.io/browse/QTBUG-18245
>
> I think Daniel's analysis in the comments is very good.
>
> I just wanted to ask, since it's such an old bug and much may have
> happened: Is there any way to achieve this currently?
>
> In my case, many of my pages react to backend (hardware) events in
> various ways, and it's tedious and error prone to always have to make
> sure I set the `target` of my Connections to null when the page is not
> active, to avoid unwanted reactions to signals.
The best I've come up with right now is to give my Page an active property:
Page.qml:
FocusScope {
readonly property bool active: Stack.status === Stack.Active
focus: active
...
}
SomePage.qml:
Page {
id: page
Connections {
target: page.active ? backend : null
onSomeSignal: doSomething();
}
...
}
But this just saves some typing. It's still error prone and repetitive
to have to check this property in my Connections.
Elvis
>
> The bug is also about the disabling of property bindings and
> animations, which I guess is also a valid point, though not so much
> for me at the moment.
>
> Cheers,
> Elvis
More information about the Interest
mailing list