qt - Resize window to fit content -


i have qglwidget, want resize given resolution (bigger containing window). intention is, window expands until widget fits inside, can't find way it.

i tried several commands after resizing qglwidget make work without success. list results here:

  • do nothing else: widget overlaps whole window. resized fit smaller window
  • mainwindow.adjustsize(): widget gets resized (0, 0)
  • mainwindow.resize(mainwindow.sizehint()): see above
  • mainwindow.resize(mainwindow.minimumsizehint()): see above

i read in this thread, before doing mainwindow resize event loop needs run recalculate new sizes, inserted qcoreapplication::processevents so, without visible effect.

so how resize window via widget?

edit

the glwidget not widget of window. embedded in splitter group box.

http://qt-project.org/doc/qt-4.8/qwidget.html#sizepolicy-prop

http://qt-project.org/doc/qt-4.8/qsizepolicy.html#policy-enum

http://qt-project.org/doc/qt-4.8/qwidget.html#setfixedsize

so assuming have qglwidget nested inside qmainwindow central widget, need set size policy of qglwidget.

for example:

qglwidget * glw; // in header qmainwindow 

...

// in constructor qmainwindow glw = new qglwidget; this->setcentralwidget(glw); glw->setfixedsize(500, 500);  this->adjustsize(); 

hope helps.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -