5
votes

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.

3

3 Answers

3
votes

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

1
votes

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;
}
0
votes

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