QSizePolicy policy = widget->sizePolicy(); policy.setHorizontalStretch(stretch); policy.setVerticalStretch(stretch); widget->setSizePolicy(policy);