Note that there are some explanatory texts on larger screens.

plurals
  1. POResizing child widget with keeping aspect ratio when parent widget resized
    primarykey
    data
    text
    <p>I have four widgets in a <code>QWidgets</code> named <code>FourWindowWidget</code> I am trying to put these four widgets in FourWindowWidget as one at top and remaining under that while the top one should always have 70% of the size of FourWindowWidget. I tried following : </p> <pre><code>QSize size = ui-&gt;FourWindowWidget-&gt;size(); ui-&gt;View1-&gt;setFixedHeight(size.height()*0.70); QHBoxLayout * lay = new QHBoxLayout(); lay-&gt;addWidget(ui-&gt;View2); lay-&gt;addWidget(ui-&gt;View3); lay-&gt;addWidget(ui-&gt;View4); lay-&gt;setMargin(0); lay-&gt;setContentsMargins(0,0,0,0); QGridLayout * mainlay = new QGridLayout; mainlay-&gt;addWidget(ui-&gt;View1,0,0); mainlay-&gt;setContentsMargins(0,0,0,0); mainlay-&gt;setHorizontalSpacing(0); mainlay-&gt;setSpacing(0); mainlay-&gt;setMargin(0); mainlay-&gt;addLayout(lay,1,0); delete ui-&gt;FourWindowWidget-&gt;layout(); ui-&gt;FourWindowWidget-&gt;setLayout(mainlay); this-&gt;update(); </code></pre> <p>Now the problem is now View1 have fixed size but size of FourWindowWidget is not fixed. It changes when I remove any other widget around it like closing dock widget. This resize is expected, or say I don't want to make it fixed. So when ever FourWindowWidget get resized its child widgets should be as per ratio set. But I am unable to do this cause 1. There is no any signal that inform resize so the height of internal widget will be calculated. 2. No other way I found to set 70% height of top widget rather than setFixedHeight in grid layout.</p> <p>I have tried with setting QSizePolicy to setHieghtForWidth but iit is not a working solution. Please suggest me to do this by any way. </p> <hr> <p>The Question is kind of duplicat of <a href="https://stackoverflow.com/questions/17013984/resizing-qt-widgets-based-on-window-size">Resizing Qt Widgets based on Window size</a> but there nobody answered.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload