How to default to the smallest possible size for a QDockWidget?
-
I have the following code:
@
QWidget *mainVSubsetWidget = new QWidget;
mainVSubsetWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
QVBoxLayout *mainVSelectLayout = new QVBoxLayout;
QVBoxLayout *cubeVolSelectLayout = new QVBoxLayout;
QVBoxLayout *buttonVolSelectLayout = new QVBoxLayout;
d_voxSubset = d_3dWidget->geoContext()->newCube();
QWidget * selectWidget = d_voxSubset->infoWidget();
cubeVolSelectLayout->addWidget(selectWidget);
mainVSelectLayout->addLayout(cubeVolSelectLayout);
QPushButton *resetVolSelectButton = new QPushButton("Reset");
buttonVolSelectLayout->insertWidget(0,resetVolSelectButton,0,Qt::AlignHCenter);
connect(resetVolSelectButton,SIGNAL(clicked()),this,SLOT(resetVSubset()));
mainVSelectLayout->addLayout(buttonVolSelectLayout);
resetVolSelectButton->setDefault(true);
mainVSubsetWidget->setLayout(mainVSelectLayout);
d_dockVSubset = new QDockWidget("V Subset",this);
d_dockVSubset->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
d_dockVSubset->setWidget(mainVSubsetWidget);
addDockWidget(Qt::LeftDockWidgetArea, d_dockVSubset);
showVSubset(0);
@So the widget is hidden by default. When I first open it up, it looks like this docked:
"initial docked":https://docs.google.com/open?id=0B3kRBMUrFam7S1lOcGZRcm1kdDA
and this undocked:
"initial undocked":https://docs.google.com/open?id=0B3kRBMUrFam7WEtBRWlYc3lGNjg
I can grab the corner or resize bar and make it smaller, to this size:
"minimum docked":https://docs.google.com/open?id=0B3kRBMUrFam7bVdib0FTTUxfNHM
and this:
"minimum undocked":https://docs.google.com/open?id=0B3kRBMUrFam7Z3dpdjY2WThVS2s
How do I do that in code? I want it to be shown as small as possible in the width direction, but be able to grow as needed when docked, if other docked widgets are added that are wider.I'm fairly new to Qt, and I have looked through the documentation and looked at using the sizeHint and such, but I'm not getting anything to work, so I must be missing something.
Thanks for the help,
HeatherKM