Project

General

Profile

Actions

Support #8278

open

Invisible widget

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

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/24/2021
Due date:
% Done:

0%

Estimated time:

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?

Actions #1

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) ...

Actions #2

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?

Actions #3

Updated by Korneel Dumon over 3 years ago

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

Actions #4

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.

Actions

Also available in: Atom PDF