Support #8278
openInvisible widget
0%
Description
I have 20 widgets that are updated not very fast. Only 2 of them are visible but paintEvent is called for all of them every time I change anything.
1) How can I check that a widget is visible / invisible to avoid slow drawing for invisible widgets?
2) How can I get a notification that a widget became visible/invisible?
Updated by Korneel Dumon over 3 years ago
Do you mean present on the page? Or not visible as in 'scrolled out of view'?
I see some methods in WWebWidget
that might help you out: isVisible()
, scrollVisibilityChanged()
(you have to enable this) ...
Updated by Alex Fedorov over 3 years ago
I mean 'scrolled out of view'.
I have several widgets on my web-page. All of them are created using widgetset feature. Wingets are bent to DIV tags in HTML. In the widget constructor I added two lines:
setScrollVisibilityEnabled(true);
scrollVisibilityChanged().connect(this, &IGLWidget::onVisibilityChanged);
Unfortunately onVisibilityChanged method is never called.
What am I doing wrong?
Updated by Korneel Dumon over 3 years ago
There is an example in 'feature/scrollvisibility', you can have a look at that.
Updated by Korneel Dumon over 3 years ago
Regarding your use of widgetset, this will have an effect on this feature (the same would be true for any nested scrollable container).
The signal will trigger if the widget's position is inside the viewport , also if it is hidden beyond the boundaries of another scrollable container. Of course, this doesn't explain why you don't get any signal.
In the process of testing this, I discovered a small bug where I get 'signal not exposed' in the server log. If you get this, try moving the call to setScrollVisibilityEnabled()
to right after widget construction.