QWidget::resize() is a nice way to change the size of a widget and to calculate the proper width you'll have to fetch the header of the table, calculate the width of all columns based on the header, add the frame of the view to the result, add the margin between the dialog border and the view, add the width of the dialog border and set that as the width of the dialog. Or you can set the size of the table widget in a similar manner (without everything that is related to the dialog) and put a constraint on the dialog's layout so that its size is fixed on its contents size.