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. else setting fixed size on widget pretty small possible without breaking layout constraints , not further.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -