title: Spacing between widgets in QHBoxLayout
body: <p>I'm trying to create a GUI with QtCreator. For this GUI, I need to display several images with different sizes next to each other. These images should be touching each other.</p>
  
  <p>I use a <code>QWidget</code> with a <code>QHBoxLayout</code>, where I add the labels (with different sizes) containing the images.</p>
  
  <p>According to related questions, I should use <code>setSpacing</code> and <code>setContentsMargin</code> to remove these spaces, but that won't work; I tried several times.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>QWidget *widget = new QWidget(ui-&gt;tagcloud);
  QHBoxLayout * l = new QHBoxLayout(widget);
  ui-&gt;tagcloud-&gt;setWidget(widget);
  
  for(int i=0;i&lt;list.size();++i)
  {
      QLabel *lab = new QLabel;
  
      QPixmap pic((list[i].imgPath).c_str());      //This fetches the image
      int sizeChange = 50 + (2*list[i].percent);   //Calculates the size of the image
  
      lab-&gt;setFixedSize(QSize(sizeChange, sizeChange));
      lab-&gt;setPixmap(pic);
      lab-&gt;setScaledContents(true);
  
      l-&gt;addWidget(lab);
      l-&gt;setSpacing(0);
  
  }
  </code></pre>
  
  <p>However, when I run this, the spacing remains the same (i.e. definitely not zero).
  If I add more labels to the layout, the spacing seems to get smaller.</p>
  
  <p>Can anyone explain or help me? Thanks!</p>