How to check if a item is currently visible on screen?
-
Hi together!
Does anybody have a good (read: "performant") solution for this issue?
I have a set of controls which have bindings to frequently changing data values. The data comes from a limited hardware-bus. Therefore, it would be better to disable the binding* while the control is not visible on screen. Items "visible"-property doesn't help in this case. So, how to determine if a Item-based QML widget is currently visible on screen (and not hidden by an overlay or currently outside the visible area)?(*The data is delivered by a c++ written stub object which has a "pause" function.)
Thanks in advance!
Frime -
Hi @Jean,
Thank you very much for your response! So, the best solution for me would be if it doesn't matter why the control is not visible on screen. The only thing I'm interested in is if a "living" instance is currently rendered or not. Other approaches, eg. checking if current surrounding page is actually displayed or checking x|y coordinates against the viewport are too expensive (too much bindings necessary).
Any idea? Thanks in advance!
Frime -
Hi @Frime
It is very important to design UI scenario because UI operates event-driven as you know.
You want to efficiently collect some data from limited hardware-bus.
And I think it is necessary to display data on one page or few number page, is it right?if yes or not, you know some condition (occur events or singals) to enter or exit the page.
You can call to stop function(data collection) when the exit condition is satisfied.Jean.
-
Hi @Jean,
yes, you're right. But in my case this is unfortunately not possible. What I am doing is developing a Toolkit with a bunch of Controls for displaying data. These controls are not used by me (even not used by really developers) but used by people who are configuring the UI pages via drag and drop in the Quick Designer. This is why the logic should be encapsulated within the control...
Thanks again!
Cheers,
Frime