Qt: How to determine whether a widget is visible or not in the QScrollArea?
Asked Answered
K

1

8

Someone suggested that I re-implement the QWheelEvent handler and check each child widgets' visibleRegion is 0 or not.

Are there any better suggestions?

Krystakrystal answered 24/2, 2015 at 15:50 Comment(1)
Nyaruko, I am looking for the same, if you get any solution please add.Raisaraise
M
4

When you add the widget. Give it a name.

QWidget* myWidget = new QWidget;
myWidget->setObjectName( "myWidget" );
...
//create scroll area
//add a layout to the scroll area
...
scrollArea->layout()->addWidget( myWidget );

Then, check visibility like so:

QWidget* widget = scrollArea->findChild< QWidget* >( "myWidget" );
std::cout << widget->isVisible() << std::endl;

You could keep a list of your widget names to more easily loop through and check when you're ready.

Mousey answered 24/2, 2015 at 17:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.