C++ resize a docked Qt QDockWidget programmatically? -
i've started working on new c++/qt project. it's going mdi-based ide docked widgets things file tree, object browser, compiler output, etc. 1 thing bugging me far though: can't figure out how programmatically make qdockwidget
smaller. example, snippet creates bottom dock window, "build information":
m_compileroutput = new qtextedit; m_compileroutput->setreadonly(true); dock = new qdockwidget(tr("build information"), this); dock->setwidget(m_compileroutput); adddockwidget(qt::bottomdockwidgetarea, dock);
when launched, program looks (bear in mind stage of development):
however, want appear this:
i can't seem happen. qt reference on qdockwidget says this:
custom size hints, minimum , maximum sizes , size policies should implemented in child widget. qdockwidget respect them, adjusting own constraints include frame , title. size constraints should not set on qdockwidget itself, because change depending on whether docked
now, suggests 1 method of going doing sub-class qtextedit
, override sizehint()
method. however, prefer not purpose, nor have tried find working solution.
i have tried calling dock->resize(m_compileroutput->width(), m_compileroutput->minimumheight())
, calling m_compileroutput->setsizepolicy()
each of options... nothing far has affected size. said, prefer simple solution in few lines of code having create sub-class change sizehint()
. suggestions appreciated.
i went through same process. after trying far many permutations of resize()
, adjustsize()
, friends on dock widgets , contained widget, none of worked, ended subclassing qlistview
, adding sizehint()
method.
now works charm.
Comments
Post a Comment