Resizing QDockWidget in Designer



  • I've done dozens of Google searches for this and can't seem to find an answer to what seems to be an obvious question. How do I size a QDockWidget in Designer (within Qt Creator) after I've placed it in my QMainWindow?

    When I hover my mouse over the QDockWidget's edge, I get the expected mouse icon with two arrows pointing away from two bars (standard resize icon), but when I click it tries to select objects. Honestly, I find this behavior quite bizarre since I can resize the MainWindow itself normally within Designer, and dragging the edge of the QDockWidget works exactly as expected while the program is running.

    When I adjust the geometry->Width property of the QDockWidget or its child in Designer, nothing happens. The child widget does have a VBoxLayout applied to it with a QTabWidget inside, so that's likely controlling the geometry since changing the width does work if I have a QPushButton (or whatever) instead of the QTabWidget. But why won't it expand in Designer with the QTabWidget there? It works exactly as expected in run-time.

    This is important to me since I've been unable to enlarge the QDockWidget ever since I added the QTabWidget. Below is a simplified version of the ui file:

    @<?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
    <class>MainWindow</class>
    <widget class="QMainWindow" name="MainWindow">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
    </rect>
    </property>
    <property name="windowTitle">
    <string>MainWindow</string>
    </property>
    <widget class="QWidget" name="centralWidget"/>
    <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>21</height>
    </rect>
    </property>
    </widget>
    <widget class="QToolBar" name="mainToolBar">
    <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
    </attribute>
    <attribute name="toolBarBreak">
    <bool>false</bool>
    </attribute>
    </widget>
    <widget class="QStatusBar" name="statusBar"/>
    <widget class="QDockWidget" name="dockWidget">
    <attribute name="dockWidgetArea">
    <number>1</number>
    </attribute>
    <widget class="QWidget" name="dockWidgetContents">
    <layout class="QVBoxLayout" name="verticalLayout">
    <item>
    <widget class="QTabWidget" name="tabWidget">
    <widget class="QWidget" name="tab">
    <attribute name="title">
    <string>Tab 1</string>
    </attribute>
    </widget>
    <widget class="QWidget" name="tab_2">
    <attribute name="title">
    <string>Tab 2</string>
    </attribute>
    </widget>
    </widget>
    </item>
    </layout>
    </widget>
    </widget>
    </widget>
    <layoutdefault spacing="6" margin="11"/>
    <resources/>
    <connections/>
    </ui>@




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.