PyQt, How to change BoxLayout's weight (size)
<p>I have a Gui layout as in the picture. 
<a href="http://i.stack.imgur.com/hFAR1.png" rel="nofollow"><img src="http://i.stack.imgur.com/hFAR1.png" alt="enter image description here"></a></p>

<p>So currently Sublayout1 and Sublayout2 are equal in size. However I want to make Sublayout1's width smaller and stretch Sublayout2's width bigger. Is there a way to do it dynamically instead of putting a fixed size. Like on Android Studio where you can set the weight of the elements within the layout. </p>

<p>Also affecting the size shouldn't affect the Bottomlayout either. Many thanks for your help. A snippet of the code is:</p>

<pre><code>sublayout1 = QtGui.QVBoxLayout()
sublayout2 = QtGui.QVBoxLayout()
plotBox = QtGui.QHBoxLayout()
plotBox.addLayout(sublayout1)
plotBox.addLayout(sublayout2) 
bottomlayout = QtGui.QHBoxLayout()
mainlayout.addLayout(plotBox)
mainlayout.addLayout(bottomlayout)
</code></pre>

<p>Use the <code>stretch</code> parameter passed to <a href="http://doc.qt.io/qt-5/qboxlayout.html#addLayout" rel="nofollow"><code>QBoxLayout::addLayout</code></a></p>

<pre><code>sublayout1 = QtGui.QVBoxLayout()
sublayout2 = QtGui.QVBoxLayout()
plotBox = QtGui.QHBoxLayout()
plotBox.addLayout(sublayout1, 1)
plotBox.addLayout(sublayout2, 2)
bottomlayout = QtGui.QHBoxLayout()
mainlayout.addLayout(plotBox)
mainlayout.addLayout(bottomlayout)
</code></pre>

<p>In the above <code>sublayout2</code> has a stretch twice that of <code>sublayout1</code> and so should be allocated more space.</p>

python qt pyqt