[PyQt] Question about laying out widgets.
Christian
chrisde88 at yahoo.de
Thu Apr 2 18:02:02 BST 2009
Hi Gabriele,
the incorrect line is:
GeneralLayout.addWidget(self.summaryBox, 3, 0)
this line needs to be changed to:
GeneralLayout.addWidget(self.summaryBoxScroll, 3, 0)
Because the summaryBox is a child of the Scroll Area, summaryBoxScroll
and you should add only the top item.
But the result is very ugly, you have a scroll area, which contains the
group box. Instead I would put the scroll area into the group box:
self.summaryBox = QGroupBox("Project Management Layout")
self.summaryBox.setMinimumHeight(100)
self.summaryBoxTopLayout = QVBoxLayout()
self.summaryBoxTopLayout.setContentsMargins(1, 1, 1, 1)
self.summaryBox.setLayout(self.summaryBoxTopLayout)
self.summaryBoxScroll = QScrollArea()
self.summaryBoxScroll.setFrameStyle(QFrame.NoFrame)
self.summaryBoxTopLayout.addWidget(self.summaryBoxScroll)
self.summaryBoxTopWidget = QWidget()
self.summaryBoxScroll.setWidget(self.summaryBoxTopWidget)
self.summaryBoxLayout = QFormLayout(self.summaryBoxTopWidget)
self.summaryBoxLayout.setSpacing(1)
self.summaryBoxLayout.setSizeConstraint(QLayout.SetMinAndMaxSize)
self.summaryBoxTopWidget.setLayout(self.summaryBoxLayout)
Further you should increase the initial frame size a bit.
Christian
PS: if you would bother me, i wouldn't help you. I am happy that I can
help you!
Gabriele Visconti wrote:
> Dear Christian,
>
> thanks again so much for helping me out this much.
> Shame on me for bothering you so much but there's still something I
> can't understand.
> All that rows which grows as far as I press the 'add' button are
> included into a QGroupBox widget. I want to make that QGroupBox
> scrollable otherwise the widget and therefore the main wondow are
> growing without stop as the rows are added inside the QGroupBox.
> To do the scroll I created a QScrollArea widget and then
> QScrollArea.setWidget(QGroupBox). This is what is mentioned in the
> example by Trolltech and in the PyQt documentation. However the
> QGroupBox remains unscrollable. I tried to specify the
> QGroupBox.setMaximumHeight() and the
> QGroupBoxLayout.setSizeConstraint() but without effect: everything
> just grows without limit.
> I tried to create a childQGroupBox to contain the rows, make
> QScrollArea.setWidget(childQGroupBox) and then add both the
> childQGroupBox and the QScrollArea to the mainGroupBox, but also this
> had no effect.
> Have you got any hint? What am I messing up?
> I attached the code so far.
>
> Thanks so much again!
>
> Gabriele <http://wizandchips.wordpress.com/>
More information about the PyQt
mailing list