Note that there are some explanatory texts on larger screens.

plurals
  1. POQListWidget that resizes instead of scrolls
    text
    copied!<p>How do you change the behavior of a <code>QListWidget</code> so that it resizes its height instead of choosing a (seemingly arbitrary) height and adding scrollbars? See screenshot:</p> <p><img src="https://i.stack.imgur.com/bp6o8.png" alt="screen shot"></p> <p>The <code>QListView</code>'s should fill up as much space horizontally as they can (creating as many "columns," if you will.) Then they wrap and make as many rows as necessary to fit all the items. These calculations should be adjusted as the window is resized. This is all working fine.</p> <p>However, what I <em>want</em> to happen is that instead of the height staying the same, the <code>QListView</code> should grow or shrink vertically and never need any scrollbars. The scrolling, if necessary, will be handled on the parent <code>QWidget</code> that hosts all of the labels and lists. It seems like once the height of the <code>QListWidget</code> is established (not sure where its default is coming from), it never changes. It is too big in some cases (see second "Test" list above) and too small in others (see first "blank maps" list above.)</p> <p>The layout above is nothing surprising: two <code>QLabel</code>'s and two <code>QListWidget</code>'s in a <code>QVBoxLayout.</code> Here are the properties I have set on the <code>QListWidget</code>'s: </p> <pre><code>setMovement(QListView::Static); setResizeMode(QListView::Adjust); setViewMode(QListView::IconMode); setIconSize(QSize(128, 128)); </code></pre> <p>(I already tried setting the horizontal and vertical scrollbar policies, but that just turns the scrollbars off, clipping the content. Not what I want.)</p>
 

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