c++ - Disable resizing of a form -
i want disable resizing form - here have tried. have changed resize policy of form following horizontalpolicy:fixed verticalploicy: fixed
i have tried following
form *w = new form(); w->setfixedsize(w->size()); w->show();
but form still gets resized dragging corners. suggestions ?
it has possible.
firstly should know, before window shown has no information of it's size - size return 0 (or invalid; or ;) ) @ point - mess entire sizing , therefore silently rejected. try
form *w = new form(); //w->ensurepolished(); w->setfixedsize(w->sizehint()); w->show();
size hint should have correct value no matter what. qwidget::ensurepolished() might necessary here, recommend trying first without - if works, why complicate things?
if still doesn't work, can try overriding resizeevent()
, setting the right size widget if user resizes else. still give user illusion of resize-ability (cursors changes on edges , on), it's last option.
edit:
#include <qtgui/qapplication> #include <qwidget> int main(int argc, char *argv[]) { qapplication a(argc, argv); qwidget w; w.setfixedsize(500,500); w.show(); return a.exec(); }
result: widget cannot resized. not change qmainwindow helped - oat least on system simple widget can ;)
Comments
Post a Comment