title: Widget under a QTabBar with unwanted frame
body: <p>I have a problem with QTabBar/QTabWidget. This is what my program looks like at the moment, using QTabBar:  </p>
  
  <p><img src="https://i.stack.imgur.com/mELC6.png" alt="enter image description here"></p>
  
  <p>As you can see, there is an unsightly line between the QTabBar and the QScrollArea underneath it. This line is part of the frame of the QScrollArea, which I can't simply get rid of, because it is required on the other three sides. I realise I could use QTabWidget, but then I would have to create a widget for each tab, which is not feasible here: the contents of the QScrollArea change according to the selected tab, but there is only one QScrollArea widget. (Duplicating it each time a new tab is created would cause its own problems.)  </p>
  
  <p>So does anybody know a way to either:<br>
  (i) tell the QScrollArea to draw a frame without the top line; or<br>
  (ii) use the same widget for each tab in a QTabWidget?</p>
  
  <p><strong>Update 3</strong> For another approach, see my answer below.</p>
  
  <p><strong>Update 1</strong> I have implemented zvezdi's suggestion, and the unsightly line has disappeared:  </p>
  
  <p><img src="https://i.stack.imgur.com/6HN2C.png" alt="enter image description here"></p>
  
  <p>This is an improvement. But it's not right. Look at the gaps between the scroll bars and the border. On the right, it's two pixels instead of one; on the bottom, it's <em>three</em> pixels. And the gap on the right between the QScrollArea border and the mainWidget border is one pixel too big. This is due to QTabWidget's border style, which I am losing my sanity trying to change. If I say:</p>
  
  <pre><code>MyTabWidget -&gt; setStyleSheet ("QTabWidget::pane { margin: 0px,0px,0px,0px }") ;
  </code></pre>
  
  <p>then the margins seem to be right, but the borders disappear:</p>
  
  <p><img src="https://i.stack.imgur.com/9Ucnh.png" alt="enter image description here"></p>
  
  <p>If I say:</p>
  
  <pre><code>MyTabWidget -&gt; setStyleSheet ("QTabWidget::pane { "
    " margin: 0px,0px,0px,0px;"
    " border: 1px solid darkgray;"
    "}") ;
  </code></pre>
  
  <p>then I'm almost back to where I started:</p>
  
  <p><img src="https://i.stack.imgur.com/8Namz.png" alt="enter image description here"></p>
  
  <p>If I try to remedy this with:</p>
  
  <pre><code>ApplicationTabWidget -&gt; setStyleSheet ("QTabWidget::pane { "
  "   margin: 0px,0px,0px,0px;"
  " border: 1px solid darkgray;"
  " border-top: 0px;"
        "}") ;
  </code></pre>
  
  <p>then again I am mocked for my pains:</p>
  
  <p><img src="https://i.stack.imgur.com/KTlUw.png" alt="enter image description here"></p>
  
  <p><strong>Update 2</strong> If I forget <code>setStyleSheet</code> and just turn <code>documentMode</code> on, this is what I get:</p>
  
  <p><img src="https://i.stack.imgur.com/oHn1s.png" alt="enter image description here"></p>
  
  <p>Please somebody, tell me I'm being stupid, and there's a perfectly simple solution to all this.</p>