Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to default to the smallest possible size for a QDockWidget?
Forum Updated to NodeBB v4.3 + New Features

How to default to the smallest possible size for a QDockWidget?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HeatherKM
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved