PDA

View Full Version : issue resizing QScrollArea pyqt5



Bybuu
13th October 2017, 09:22
Hello,

I would like to know if its possible to resize a scroll area to see all the label inside after the init of the window (on pyqt5)

currently if there is a long label at the init the window, the scroll area will take the place it needed as I want.

But if I click on a button, and it change the text of the label in the scroll area from a shor text to a very long text, then it will not change the size of the scroll area.



def __init__(self, parent):
super(PathConfiguration,self).__init__()
self.initUI( parent )

def initUI( self, parent ):
self.button = QtWidgets.QPushButton(tr_(u"Set PATH"), parent)
self.button.clicked.connect(self.do_it)

self.scroll_area = QtWidgets.QScrollArea()
self.scroll_area.setWidgetResizable(True)

self.status = QtWidgets.QLabel()
self.scroll_area.setWidget(self.status)
self.scroll_area.setWidgetResizable(True)

self.scroll_area.setToolTip(self.toolTip())

hbox = QtWidgets.QHBoxLayout(parent)
hbox.addWidget(self.button)
hbox.addWidget(self.scroll_area)
self.setLayout(hbox)



def do_it( self ):
self.status.setText(message)


where message can be a very long message as a short one.

so to be clear, at the init if the text is short it will take small place as I want, If it is long text it will be big as I want, so every thing is fine here.
but when i click on the button to change the text, to go from a short text to a long text, the scroll area is not changing from short to big one.

Do you have any idea or line of code i should put it in.

See you ;)