Someone suggested that I re-implement the QWheelEvent
handler and check each child widgets' visibleRegion
is 0 or not.
Are there any better suggestions?
You can set your push button checkable an d connect clicked(bool) with setVisible(bool) of your widget. @abhay To add to @Roy44 's answer you can just connect button's clicked signal to hide and show slots.
Widgets are the primary elements for creating user interfaces in Qt. Widgets can display data and status information, receive user input, and provide a container for other widgets that should be grouped together. A widget that is not embedded in a parent widget is called a window.
Try putting the button you want to hide and unhide in another layout. In that layout along with the button put a spacer. Call Button hide and spacer will take over. Spacer takes over hidden button's space.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With