[Interest] PySide2 : QHBoxLayout content sizing

Tony Rietwyk tony at rightsoft.com.au
Mon Jul 12 04:41:20 CEST 2021


Doh!   I assumed ui_inputs and ui_outputs were QWidgets, not QLayouts - 
sorry!

Try setStretch or setStretchFactor instead - unfortunately, my Qt 
Designer is broken, so I can't check those myself.

Regards, Tony


On 12/07/2021 12:26 pm, Nicholas Yue wrote:
> Hi Tony,
>
>   Are you able to share the method/API call to set the minimum width ?
>
> Cheers
>
> On Sun, 11 Jul 2021 at 18:12, Tony Rietwyk <tony at rightsoft.com.au 
> <mailto:tony at rightsoft.com.au>> wrote:
>
>     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  <mailto:Interest at qt-project.org>
>>     https://lists.qt-project.org/listinfo/interest  <https://lists.qt-project.org/listinfo/interest>
>     _______________________________________________
>     Interest mailing list
>     Interest at qt-project.org <mailto:Interest at qt-project.org>
>     https://lists.qt-project.org/listinfo/interest
>     <https://lists.qt-project.org/listinfo/interest>
>
>
>
> -- 
> Nicholas Yue
> https://www.linkedin.com/in/nicholasyue/ 
> <https://www.linkedin.com/in/nicholasyue/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210712/18176ec6/attachment.html>


More information about the Interest mailing list