Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding a QWidget's height before inserting
    primarykey
    data
    text
    <p>I have a widget to insert that looks like this</p> <pre><code>+--------------------+ | +-------++-------+ | | | || | | | | || | | | | || Label | | | | Label || Label | | | | || | | | | || | | | +-------++-------+ | +--------------------+ </code></pre> <p>A QWidget element containing two QVBoxLayouts, each containing one or more QLabels.<br>This Widget is going to be inserted in a Vertical Layout that has a stretch cell, so all the widgets of this kind will go to the top and shrink to the smaller height possible.</p> <p>Resulting in something like this.</p> <pre><code>______________________ ← Layout boundary +--------------------+ | +-------++-------+ | | | || Label | | | | Label || Label | | ← Widget shrunk to the smallest | +-------++-------+ | +--------------------+ ______________________ ← Layout boundary ↑ | | ← Spacer | ↓ ______________________ ← Layout boundary </code></pre> <p>But before doing this insert, I want to know the size that the widget would have in the inserted layout. Maybe the minimum size allowed by its internal layout. Not sure how to call it.</p> <p>I have tried already many approaches like inserting the widget in an alternate invisible layout so I can retrieve its height when inserted, which should be the same that the widget would take when inserted in my definitive layout.</p> <p>But for some reason I always get 480 or 478 when the widget is at most 50px height when pressed vertically. So I am totally lost.</p> <p>I have to do this because I need the widget to animate when inserting, and I need to know the height it will take for me to animate from height 1 to it.</p> <p>How can I do this?</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