title: Qt widget with minimal size to fit all contents
body: <p>I'd like to have a <code>QWidget</code> instance that uses a <code>QHBoxLayout</code> and (ideally automatically, but upon calling some function is fine too) resizes horizontally to fit its contents. Horizontal resizing is enough since all widgets, including the container itself, will have the same height.</p>
  
  <p>The use case is the following: The widget, let's call it container, is floating, i.e. not part of any layout. A user should be able to add further widgets with a fixed size (by calling a function) to the container's layout, upon which the container grows to fit its new contents. The user should also be able to remove a previously added widget, upon which the container shrinks again. The container will not be created until the first widget is inserted and deleted when the last one is removed, i.e. it will always contain at least one widget.</p>
  
  <p>An example: after adding the first widget, the container looks like this, with <code>|</code> being its left/right borders:</p>
  
  <pre><code>|&lt;1st widget&gt;|
  </code></pre>
  
  <p>After adding another one, it looks like this:</p>
  
  <pre><code>|&lt;1st widget&gt;  &lt;2nd, longer widget&gt;|
  </code></pre>
  
  <p>After removing the first widget, it looks like this:</p>
  
  <pre><code>|&lt;2nd, longer widget&gt;|
  </code></pre>
  
  <p>I suspect that this should be kind of simple, but I got lost somewhere inbetween container's <code>sizeHint</code>, <code>sizePolicy</code>, <code>adjustSize()</code>, and its layout's <code>sizeContraint</code> as well as several attempts with explitely setting the size and forcing updates and essentially got nowhere (i.e. the container not resizing at all, the container only growing but not shrinking, etc). I suspect that I must have missed something kind of obvious..?</p>