PySide Qt: Auto vertical growth for TextEdit Widget, and spacing between widgets in a vertical layout

Viewed 5444

enter image description here

I need to Solve two problems With my widget above.

  1. I'd like to be able to define the amount of space put between the post widgets shown in the image (they look fine as is, but I wanna know it's done).
  2. I'd like to grow the text edits vertically based on the amount of text they contain without growing horizontally.

For 1 the code that populates the widgets is as follows :

self._body_frame = QWidget()
self._body_frame.setMinimumWidth(750)
self._body_layout = QVBoxLayout()
self._body_layout.setSpacing(0)
self._post_widgets = []
for i in range(self._posts_per_page):
    pw = PostWidget()
    self._post_widgets.append(pw)
    self._body_layout.addWidget(pw)

    self._body_frame.setLayout(self._body_layout)

SetSpacing(0) doesn't bring things any closer, however SetSpacing(100) does increase it.

edit

(for Question 2) I haven't mentioned this, but I want the parent widget to have a vertical scrollbar.

I have answered my own question, but its wordy, and cause and affect based. A proper well written tutorial style answer to address both points gets the bounty :D

edit 2

Using my own answer below I have solved the problem. I'll be accepting my own answer now.

enter image description here

2 Answers
Related