views:

175

answers:

1

Let's consider we have QWidget that contains QTableWidget (only). So we want to resize the table by resizing the widget, and we dont want to have an indet between the QWidget border and cells of the table. What kind of property is making posible for QTableWidget to be aligned with the borders of it parent widget?

Thanks.

+2  A: 

First, you want to make sure the QTableWidget is placed inside a layout. For instance,

QTableWidget* tw = new QTableWidget(parent_widget);
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(tw);
parent_widget->setLayout(layout);

assuming parent_widget is already pointing to the widget containing the QTableWidget. This will ensure that the table resizes when the parent widget does. To have the table fill the entire space of the widget, just set the margin to zero on the layout. Try one of these:

layout->setMargin(0);

or

layout->setContentsMargins(0,0,0,0);
Jason
Seems like it doesn't work. Layout does not help.
Narek
can you provide some sample code?This answer is absolutely correct, and it seems, that there is some another problem.Maybe you do not want any border at all? Then you must set table's frameShape to NoFrame.
Max
Right! Ok thank you!
Narek