Project

General

Profile

Support #8278

Invisible widget

Added by Alex Fedorov 4 months ago. Updated 4 months 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?

#1

Updated by Korneel Dumon 4 months 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) ...

#2

Updated by Alex Fedorov 4 months 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?

#3

Updated by Korneel Dumon 4 months ago

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

#4

Updated by Korneel Dumon 4 months 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