I'm currently trying to adapt a vertical scrollbar's step size to the height of the objects inside the scrollable and responsive QVBoxLayout. So that one scroll step exactly scrolls one widget down. All objects inside the QVBoxLayout do have the same geometry.
Therefore I would need the current (live) height of one of the objects inside the QVBoxLayout. I have already tried the following methods:
The object is initialized with a height of 300 (not fixed). The height is then adapted dynamically by resizing the window including the QVBoxLayout.
QWidget* pWidget = PointerToMyWidgetInsideQVBoxLayout;
std::cout << "height:" << pWidget->height() << std::endl; /// @todo PHIL: height gives only initial value, not current height
std::cout << "geometry-height:" << pWidget->geometry().height() << std::endl;
std::cout << "frameSize-height:" << pWidget->frameSize().height() << std::endl;
std::cout << "frameGeometry-height:" << pWidget->frameGeometry().height() << std::endl;
std::cout << "normalGeometryheight:" << pWidget->normalGeometry().height() << std::endl;
std::cout << "minimumHeight-height:" << pWidget->minimumHeight() << std::endl;
std::cout << "maximumHeight-height:" << pWidget->maximumHeight() << std::endl;
std::cout << "sizeHint-height:" << pWidget->sizeHint().height() << std::endl;
This results in the following output:
height:300
geometry-height:300
frameSize-height:300
frameGeometry-height:300
normalGeometryheight:300
minimumHeight-height:0
maximumHeight-height:16777215
sizeHint-height:50
Many thanks in advance for your help!
The method QWidget::height()
returns the actual size of the widget, not only the one at initialization: see this answer.