5

I have a QTabWidget with a QTableWidget inside, as the example below:

enter image description here

But it has a "padding" (at least I think it is a padding) in the QTabWidget (marked as red in the figure).

How can I remove that or expand the QTableWidget to fill the QTabWidget area?

I am using Qt 5.3.

KelvinS
  • 2,870
  • 8
  • 34
  • 67

3 Answers3

3

Try something like this :

tabwidget.setStyleSheet("QTabWidget::pane { 
 margin: 0px,1px,1px,1px;
 border: 2px solid #020202;
 border-radius: 7px;
 padding: 1px;
 background-color: #E6E6E3;
}");

Hope this help you

lntl
  • 41
  • 5
2

The problem seems to be related to the "pane" margin of the QTabWidget.

I solved the problem by using this on the stylesheet:

QTabWidget::pane {
    border: 0 solid white;
    margin: -13px -9px -13px -9px;
}
KelvinS
  • 2,870
  • 8
  • 34
  • 67
0

When you put QTableWidget to QTabWidget tab, you can right click on it (QTabWidget) and select Lay out -> Lay out vertically (for example, or horizontally), this will add an verticalLayout element and place your QTableWidget into it, filling the whole tab. Then, select newly created verticalLayout, scroll down to Layout section, and from here you can control layoutLeftMargin, layoutTopMargin, layoutRightMargin and layoutBottomMargin properties:

Qt Creator, UI Editor, Layout Margins

Setting all of them to 0, will give you desired result (no stylesheets involved):

enter image description here

Dmitriy
  • 515
  • 7
  • 14
  • Hi @Dmitriy, thanks for the answer. Actually, I added a Vertical Layout to my QTabWidget (using the upper layout menu from the Qt Design) but the Layout options does not appear on my Property Editor. – KelvinS Feb 16 '17 at 17:44
  • I am looking for something similar, but in your example, you can still clearly see a 1 pixel margin between the inner frame and the tab widget itself. So, it does not remove it completely? – 1313e Oct 01 '19 at 04:01