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. QDockWidget doesn't resize after add widget
Forum Updated to NodeBB v4.3 + New Features

QDockWidget doesn't resize after add widget

Scheduled Pinned Locked Moved Solved General and Desktop
qdockwidgetresize
7 Posts 3 Posters 3.9k 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.
  • Gianluca86G Offline
    Gianluca86G Offline
    Gianluca86
    wrote on last edited by
    #1

    Hi everyone,
    I'm using a QDockWidget in MainWindow. When I insert a widget (in my case a table) into the dock, it does not expand with the widget, but it expands to a fixed size and then the scrollbar appears.
    However, if the widget is smaller than this initial fixed size, the Dock fits.
    But I didn't set any minimum or maximum size.
    Here is the dock code:

    QDockWidget *pPropertyDock = new QDockWidget(this);
    pPropertyDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    pPropertyDock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
    pPropertyDock->setWindowTitle(DOCK_TITLE);
    pPropertyDock->setObjectName(DOCK_OBJECTNAME);
    addDockWidget(Qt::RightDockWidgetArea, pPropertyDock);
    

    According to what the documentation says, the Dock should be adapted to the child widget.
    I do not understand where this maximal initial width comes from.
    Anyway I can extend it by hand, but I would like to extend in automatic.

    I hope I explained myself

    Thank you

    jsulmJ 1 Reply Last reply
    0
    • Gianluca86G Gianluca86

      Hi everyone,
      I'm using a QDockWidget in MainWindow. When I insert a widget (in my case a table) into the dock, it does not expand with the widget, but it expands to a fixed size and then the scrollbar appears.
      However, if the widget is smaller than this initial fixed size, the Dock fits.
      But I didn't set any minimum or maximum size.
      Here is the dock code:

      QDockWidget *pPropertyDock = new QDockWidget(this);
      pPropertyDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
      pPropertyDock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
      pPropertyDock->setWindowTitle(DOCK_TITLE);
      pPropertyDock->setObjectName(DOCK_OBJECTNAME);
      addDockWidget(Qt::RightDockWidgetArea, pPropertyDock);
      

      According to what the documentation says, the Dock should be adapted to the child widget.
      I do not understand where this maximal initial width comes from.
      Anyway I can extend it by hand, but I would like to extend in automatic.

      I hope I explained myself

      Thank you

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Gianluca86 Is your dock widget in a layout?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Gianluca86G Offline
        Gianluca86G Offline
        Gianluca86
        wrote on last edited by
        #3

        I hope not to misunderstand the question, but anyway no, I created the Dock inside the Mainwindow (addDockWidget (Qt :: RightDockWidgetArea, pPropertyDock)), while in the mainWindow centralWidget there is another widget.
        To insert the table into the Dock I simply used the command "setWidget" of QDockWidget.

        1 Reply Last reply
        0
        • Gianluca86G Offline
          Gianluca86G Offline
          Gianluca86
          wrote on last edited by
          #4

          For more information:
          the "Dock Widgets Example" show the problem.

          mrjjM 1 Reply Last reply
          0
          • Gianluca86G Gianluca86

            For more information:
            the "Dock Widgets Example" show the problem.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Gianluca86

            Hi
            Im not sure i understand.
            alt text

            So the issue is that the dock is smaller than the QListWidget?

            The dock seems to have the size from the area allocated when created.
            Since there it no way it can adjust the splitter or the mainwindow size, how would it grow to fit the widget?

            1 Reply Last reply
            0
            • Gianluca86G Offline
              Gianluca86G Offline
              Gianluca86
              wrote on last edited by
              #6

              So there is no way to adjust the area where the dock is allocated?
              Can you do it only by hand?

              mrjjM 1 Reply Last reply
              0
              • Gianluca86G Gianluca86

                So there is no way to adjust the area where the dock is allocated?
                Can you do it only by hand?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Gianluca86
                You can make main window bigger and move the splitter. then
                it should be bigger.

                1 Reply Last reply
                1

                • Login

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