[Interest] PySide2 : QHBoxLayout content sizing

Tony Rietwyk tony at rightsoft.com.au
Mon Jul 12 03:10:22 CEST 2021


Hi Nicholas,

You could set a minimum width on them based on the expected width - 
don't forget to set it back to 0 when you add their true content.

Regards, Tony


On 12/07/2021 7:27 am, Nicholas Yue wrote:
> Hi,
>
> I have a horizontal layout, self.viewHorizontalLayout
>
> I am adding the following items
>
>         # Inputs/View/Outputs panel
>         self.ui_inputs = QtWidgets.QVBoxLayout()
>         self.ui_inputs.addStretch(1)
>         # inputs.addWidget(QPushButton('inputs'))
>         self.viewHorizontalLayout.addLayout(self.ui_inputs)
>
>         self.ui_scene = QtWidgets.QGraphicsScene() # Object lifetime 
> critical
>         self.ui_view = QtWidgets.QGraphicsView(self.ui_scene)
>         self.viewHorizontalLayout.addWidget(self.ui_view)
>
>         self.ui_outputs = QtWidgets.QVBoxLayout()
>         # outputs.addWidget(QPushButton('outputs'))
>         self.viewHorizontalLayout.addLayout(self.ui_outputs)
>
> As self.ui_inputs and self.ui_outputs are initially empty, 
> self.ui_view occupies the entire self.viewHorizontalLayout
>
> Is there some hints/size/stretch I can set on self.ui_inputs and 
> self.ui_outputs so that later on, when I do add items to them, it does 
> not pop in size to accommodate the additional content ?
>
> Cheers
> -- 
> Nicholas Yue
> https://www.linkedin.com/in/nicholasyue/ 
> <https://www.linkedin.com/in/nicholasyue/>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210712/a3770b9a/attachment.html>


More information about the Interest mailing list