c++ - Resize a window such that the primary widget is a specific size -
i have qt application qmainwindow has menu, toolbar , primary widget. i have menu item resize application primary widget specific size yet figure out way this. so far, closest have come this: void on_actionsetsize_triggered() { ui_.primary_widget->setminimumsize(100,200); adjustsize(); } the idea being set primary widgets minimum size target size, , ask ui "shrink fit" unfortunately, seems work sporadically @ best, increase size when needed, when want reduction in size, doesn't work :-/. note: want allow user freely resize application, when ask. for size reduce while increased need set fixed size on primary widget before calling adjustsize() . can release constraint allow user re-size henceforth. you try this: ui_.primary_widget->setfixedsize(100, 200); adjustsize(); ui_.primary_widget->setmaximumsize(qwidgetsize_max, qwidgetsize_max); do note size setting on primary widget needs valid size based on what's inside it. ...