Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Qt Creator] Layouts inside a DockWidget
Qt 6.11 is out! See what's new in the release blog

[Qt Creator] Layouts inside a DockWidget

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 2 Posters 6.4k 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.
  • M Offline
    M Offline
    Muzza
    wrote on last edited by
    #1

    Hi,

    Using QT Creator, I'm trying to create a dock widget that has a series of other gadgets inside it (buttons, combo boxes and a tree widget), and have the gadgets auto-expand horizontally as the dock widget is resized.
    I know it can be done in pure C++ code, and I've done the same thing using layouts in other Apps that don't require docks, but I can't get it to work in the designer inside a dock.

    To recreate my problem, just create a fresh App, add a Dock Widget, add some gadgets to the dock, select them and choose 'Layout in a group form'. After doing this I can't seem to find any combination of settings that automatically resize the widgets when the dock is resized.
    Am I just getting the settings wrong (what should they be??) or am I doing this completely wrong?
    It seems like something that should be very easy to do, but I'm having no luck at all.

    Thanks for any help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      IIRC, QDockWidget is just a container, so basically, you set a widget on it, and the other gadgets on that widget.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Muzza
        wrote on last edited by
        #3

        Yes, I didn't mention it, but QT Creator automatically places a QWidget under the QDockWidget, and so everything is placed under that. But I still can't get it to work as I'd like it to.

        I think that the QWidget under QDockWidget needs to BE the QFormLayout, but whenever I create the layout QT Creator automatically creates a new QFormLayout instead.

        i.e. I think it should be this:
        @
        -QDockWidget
        -QFormLayout
        -QPushButton
        -etc
        @

        but when I create the layout QT creator sets it up like this:

        @
        -QDockWidget
        -QWidget
        -QFormLayout
        -QPushButton
        -etc
        @

        I don't know how to persuade Creator to do the former (if the former is indeed correct)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The later is the correct version. Programmatically, you would create the widget (and all what goes inside) then the QDockWidget, and assign the widget to the DockWidget.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Muzza
            wrote on last edited by
            #5

            ok, well there must be something I'm doing wrong elsewhere, as although the form layout works, nothing resizes with the dock widget :(

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Muzza
              wrote on last edited by
              #6

              Figured it out.

              In my first post I said
              "add some gadgets to the dock, select them and choose ‘Layout in a group form’. "

              This is wrong, I needed to add the gadgets to the dock, then select the DOCK and choose 'Layout in a group form'.
              Seems obvious now, but was driving me mad earlier.

              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