Find out when a QScrollArea scrollbar is shown
-
I need to resize content inside a
QScrollArea
when the scrollbar is being shown due toScrollBarAsNeeded
policy, but there are no show or hide signals forQWidget
nor did i find anything useful inQScrollBar
orQAbstractSlider
.What would be the procedure to do something like that ?
-
Just thinking out loud, but what happens when you compare the size of the frame contained in the QScrollArea with the size of the QScrollArea itself? Does the child frame size() return its real size, or the visible size within the ScollArea? Test it and see...
-
Hi
If its visible, this seems to return the status fine
qDebug() << "is there : " << ui->scrollArea->verticalScrollBar()->isVisible(); -
@Kent-Dorfman That is not an issue here, i can calculate the size of the area inside fine (that is already what i am doing), my problem is that sometimes there are no scrolbar and sometimes there is, when i calculate the size of my
QWidget
which is relative to the size of the inside area, i do it when i insert it, but by that point, the scrollbar is not there yet if it were to be.What i need is some kind of event that triggers when the scrollbar appears, so i can re-calculate everything.
-
@reonZ said in Find out when a QScrollArea scrollbar is shown:
What i need is some kind of event that triggers when the scrollbar appears, so i can re-calculate everything.
Well, you could use an eventfilter and watch for the showEvent for the scrollbar(s)