Looking for Control.noShown signal
-
Hello,
I am making HMI for machine working on the CAN bus.
So, it is important to keep the bus load as low as possible.For this, I need to request parameters only for visible on UI parameters. Like I don't need "CurrentSpeed", if on UI user currently activated view with "Settings".
But I am missing a signal from Control what saying: "Hi. I am TextVew for CurrentSpeed. And User just open Layout with me!".
And I can ask for updates from PLC only for this parameter(s).Can you help me, please?
Mikl
-
Temporary, I solved it with:
Button { property string control ... Component.onCompleted: panel.controlShowed(control) ... }
But hot sure what it is a good idea.
-
Let's consider a Label displaying a value, I assume you are showing the value of a property of some device.
What you might currently be doing now is (keep in my that I don't know how CAN works or how you are actually using it):
Label { text: CanController.device(deviceName).propertyName }
If I understand correctly your problem, it's that the CAN controller has to always update the property because it doesn't know when it's needed or not.
I would consider 2 solutions :
- Use an instantiable type to access your CAN values, and update the value only when an instance exists/is enabled
Label { id: myLabel CanProperty { id: myProperty device: deviceName property: propertyName enabled: myLabel.visible // optional, maybe just relying on the automatic destruction of the Label is enough for you (only works if you remove/replace your controls/pages, not if you simply hide them) } text: myProperty.value }
- Use an attached property ( https://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html#providing-attached-properties ) to hold a handle on a property that will tell the controller to keep updating its value when the handle exists/is enabled (in the c++ implementation of the attached object, you can connect to the visibleChanged signal of the Item to enable/disable the handle)
Label { id: myLabel CanHandle.device: deviceName CanHandle.property: propertyName text: CanController.device(deviceName).propertyName // same API as before here }
I don't really know what your current code looks like, so I'm not sure if it's applicable but that's something I would do.
-
Thank you for your answer
My problem is, that I need to request only 10 of 50 possible properties on CanBus. The ones showed on UI
If i understand your proposal correct, you showing how to "bind" "Label.text" to "device.property"
Maybe i overlook this, but I don't see how it is informing CanController what properties to request