PDA

View Full Version : QDialog setting maximum width to content



warchild
30th March 2012, 10:52
Hi,

I have a dialog with a QTableWidget (among others). User are able to resize the dialog but i would like the maximum width to be equal to the table widget width. The best maximum width of the table widget is when the resize mode of the horizontal header is set to QHeaderView::ResizeToContents.

A more desierable functionality would be to have QHeaderView::Stretch as the resize mode of the table but still, have the maximum width constrained to content width as if the mode where QHeaderView::ResizeToContents. So when the dialog is resized the table widget is able to shrink but the maximum size would still be constrained, as described above.

I have no idea how to do this.

wysota
2nd April 2012, 14:08
Calculate the width of all the columns in the table and set it (+all margins and frames) as the maximum width of the window widget.