Repainting QScrollArea
-
I have a horizontal
QScrollArea, loaded with aQLabel.
At some point I make changes to theQLabeland load it with shorter text.
The problem is that after I load the shorter text, the horizontal scroll bar is still showing (although not needed). It's still showing, fitting the previous text length. Note that I see the text changed successfully, but the scroll bar isn't updated as expected.I tried the following as mentioned here:
QScrollArea::update()
QScrollArea::repaint()QScrollBar::update()
QScrollBar::repaint()QScrollArea()::viewport()->update();
QScrollArea()::viewport()->repaint();None of them worked.
-
Hi,
Did you check that the size of the label changes after you set the text ?
-
Setting the widgetResizable property to
trueshould do what you want. No need to call update or repaint. They mostly just invoke a paint event. They don't adjust sizes. -
@Moderators - It worked, thanks!