Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make Qt subwidget height equal?
    primarykey
    data
    text
    <p>I have some <code>QDockWidget</code>s (not floating, only closable) inside a single <code>QWidget</code>. I have some widgets inside each <code>QDockWidget</code> - their heights should be equal. These inner widgets can be hidden through the context menu.</p> <p>My inner widgets should have equal height. I done it this way:</p> <pre><code>void MyDocksPanel::redistributeSpace() { QBoxLayout * lay = (QBoxLayout *)layout(); for (int i = 0; i &lt; lay-&gt;count(); i++) { QWidget * dock = lay-&gt;itemAt(i)-&gt;widget(); if (dock == NULL) continue; int size = 0; foreach(QWidget * subWidget, dock-&gt;findChildren&lt;QWidget*&gt;()) size += subWidget-&gt;isVisible() ? 1 : 0; if (dock-&gt;isVisible() &amp;&amp; (size == 0)) dock-&gt;hide(); lay-&gt;setStretch(i, size); } } </code></pre> <p>All works fine until I add some const elements to each <code>QDockWidget</code>: some horizontal scrollbars and some Labels... Now my inner widgets have different sizes. But it is necessary for me to set their heights strongly equal.</p> <p><code>QLayout</code> lays out widget sizes on one level of a widget's hierarchy. How can I make height-equal subwidgets?</p> <p>3 subwidgets vs 2 subwidgets</p> <p><img src="https://i.stack.imgur.com/tx5ky.png" alt="First picture"></p> <p>My first strategy to set stretches 3 and 2:</p> <p><img src="https://i.stack.imgur.com/Ci0Pg.png" alt="enter image description here"></p> <p>But, when i have added scroll bars:</p> <p><img src="https://i.stack.imgur.com/Dvi14.png" alt="enter image description here"></p> <p>Heights of my 5 widgets are equals to 37,37,37,28,28 ... and thats the problem</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.
    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