title: Qt Application Width increases when widgets visibility changes
body: <p>I have developed a <code>Qt</code> application using <code>C++</code>. I have following widgets added to <code>QHLayout</code>:</p>
  
  <pre><code>QHBoxLayout *layout = new QHBoxLayout(widget);
  layout-&gt;addWidget(sideBar_);
  layout-&gt;addWidget(chromeTabs_, 1);
  layout-&gt;addWidget(concPlot_, 1);
  layout-&gt;addWidget(od_, 1);
  layout-&gt;addWidget(settingWidget_);
  layout-&gt;setContentsMargins(0, 0, 0, 0);
  layout-&gt;setMargin(0);
  layout-&gt;setSpacing(0);
  
  setCentralWidget(widget);
  </code></pre>
  
  <p>Initially, <code>sideBar_</code> and <code>chromeTabs_</code> are visible. Then, a user can make <code>settingWidget_</code> visible by clicking on some button. When a user clicks on <code>OD button</code>, <code>chromeTabs_</code>  becomes invisible and <code>od_</code> becomes visible. However, my <code>Qt</code> application doesn't adjust itself and width of the application increases. I have to click on <code>Maximize</code> button to adjust it to the width of my laptop screen. I am unable to fix this issue. Can somebody help?</p>
  
  <p>My code base is huge. So, I can't post my code over here.</p>
  
  <p>Picture 1: After starting the application. :
  <a href="https://i.stack.imgur.com/tsGW7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tsGW7.png" alt="enter image description here"></a></p>
  
  <p>Picture 2: After making settingWidget_ visible. Initially, <code>sideBar_</code> and <code>chromeTabs_</code> are visible. The application width adjusts automatically.
  <a href="https://i.stack.imgur.com/AXvxM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AXvxM.png" alt="enter image description here"></a></p>
  
  <p>Picture 3: After making chromeTabs_ invisible and making od_ visible. You can see application width has increased.
  <a href="https://i.stack.imgur.com/xCp4w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xCp4w.png" alt="enter image description here"></a></p>
  
  <p>Picture 4: After clicking on <code>Maximize</code> button. The application fits to the screen now.
  <a href="https://i.stack.imgur.com/s8CeW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s8CeW.png" alt="enter image description here"></a></p>