Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDockWidget ignores layouts and size policy from the form
Qt 6.12 LTS is out! See what's new in the release blog

QDockWidget ignores layouts and size policy from the form

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 554 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.
  • bibasmallB Offline
    bibasmallB Offline
    bibasmall
    wrote on last edited by
    #1

    Hello!
    I'm subclassing from QDockWidget and I want my class to use form. I've made a form based on QWidget and included ui class in my QDockWidget based class. But the build result differs from the Qt Designer preview, because QDockWidget completely ignores all the preset size policies and layouts from the form. My form looks fine if used in a QMainWindow-based class and also in a QWidget-based, but not in a QDockWidget-based. How to use forms for QDockWidget?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      That's not how you're supposed to use QDockWidget. It already has a layout and adds stuff to it dynamically, e.g the title bar. Subclassing it and trying to impose the ui stuff messes with its internals.

      Don't subclass QDockWidget. Instead make a normal QWidget with all the designer ui stuff and add it to a plain dock via QDockWidget::setWidget().

      1 Reply Last reply
      3
      • bibasmallB Offline
        bibasmallB Offline
        bibasmall
        wrote on last edited by
        #3

        Thank you for your help, it works great!

        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
        • Unsolved