The call to resizeColumnsToContents() in the __init__ function has no effect, since the table is not yet visible and therefore the geometry has not yet been calculated. This happens only just prior to the showEvent(). So the place to put this is to override showEvent() for your TDDlg and call it there. You'll also need to call it again each time the table contents changes. For that, you'll need to connect a slot to one of the model's signals that indicates a change (such as dataChanged()).