Support #8278


Invisible widget

Added by Alex Fedorov over 2 years ago. Updated over 2 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


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?

Actions #1

Updated by Korneel Dumon over 2 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) ...

Actions #2

Updated by Alex Fedorov over 2 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:

scrollVisibilityChanged().connect(this, &IGLWidget::onVisibilityChanged);

Unfortunately onVisibilityChanged method is never called.

What am I doing wrong?

Actions #3

Updated by Korneel Dumon over 2 years ago

There is an example in 'feature/scrollvisibility', you can have a look at that.

Actions #4

Updated by Korneel Dumon over 2 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.


Also available in: Atom PDF