0

Using pyside2 and PyQt and I want to be able to do label.setText() in order to set text inside the scroll area. This seems fairly simple, but the issue is that when I run this it cuts off everything other then the first letter of the string sent to .setText() and doing QSizePolicy things doesn't seem to fix the issue.

Here's the code I currently have as my widgets class:

class widgets (QMainWindow) :
    def __init__ (self ) :
        QMainWindow.__init__(self)

        self.label1 = QLabel(self)
        self.scrollablel1 = QScrollArea(self)
        self.scrollablel1.setWidget(self.label1)

        self.label1.setText("foo \n bar \n 2000")

The result of this is

this

As you can see it cuts off all of the text except for the first little bit.

I've tried adding a few more things to no avail, such as:

self.label1.setContentsMargins(0,0,0,0)
self.label1.setSizePolicy( QSizePolicy.MinimumExpanding ,  QSizePolicy.MinimumExpanding )
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

Well been thinking/researching about this for a while now and am embarrassed to say I've just come across the solution. All you've got to do is add:

self.scrollablel1.setWidgetResizable(True)

And it works just fine!