PDA

View Full Version : Get maximum size a widget can get



joseprl89
8th August 2011, 08:57
Hi,

I am trying to align the widgets of my application to the center of the window. To do so, I have been placing a HorizontalSpacer on both sides of the collection of widgets that I have placed on the QMainWindow.

It has done the trick to almost every tab I have been using. But I have some issues on some tabs I only display a table on them.

The table is dinamically created from the database (the columns, columns names, whether it is editable or not, the type of each column,...) and I don't know the size that would fit better to each table to set a fixed width, and the result is a table with a small width, and lots of spaces on each side.

Is there a way to obtain the maximum size I could use without getting into trouble? I have tested:



void MyTableWidget::resizeTable(){
int width = 0;
for(int i = 0 ; i < columnCount() ; i++){
width += columnWidth(i);
}
setMinimumWidth(width);
}


But when the QMainWindow is small or the table is too big, part of the table is not visible (even with the scroll).

Cheers,

Josep