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. Preventing widget with layout from expanding in QSplitter
Qt 6.11 is out! See what's new in the release blog

Preventing widget with layout from expanding in QSplitter

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by
    #1

    I have a complex widget and layout that sits in a QSplitter, and want the QSplitter to keep the widget at a fixed size unless collapsed, while allowing the other widgets the expand at will. The form is created in QtCreator.

    See screenshot:

    !http://content.screencast.com/users/patrickkidd/folders/Snagit/media/db12f9aa-a65b-41e6-96db-d9421b78724c/2014-10-29_12-57-37.jpeg(http://content.screencast.com/users/patrickkidd/folders/Snagit/media/db12f9aa-a65b-41e6-96db-d9421b78724c/2014-10-29_12-57-37.jpeg)!

    !http://content.screencast.com/users/patrickkidd/folders/Snagit/media/bfde49df-b0b8-4d25-8f19-82ca5f15ee61/2014-10-29_13-04-26.jpeg(http://content.screencast.com/users/patrickkidd/folders/Snagit/media/bfde49df-b0b8-4d25-8f19-82ca5f15ee61/2014-10-29_13-04-26.jpeg)!

    Thanks!

    https://alaskafamilysystems.com/

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jazzco
      wrote on last edited by
      #2

      Hi Patrick,

      there are at least two solutions for this:

      1. Take the top widget out of the splitter and tell it to have the "Fixed" sizePolicy.

      2. Tell the splitter to use only the lower widgets for scaling. There is no GUI setting for this, so you need to do it in source (e.g. in constructor). It would look like:
        @
        // The stretchFactor has a default of 0,
        // so leave index 0 at default
        ui->vSplitter->setStretchFactor(1,1);
        ui->vSplitter->setStretchFactor(2,1);
        @

      With the second solution, the user will be able to resize the height of the top widget manually by dragging the splitter below it. The first solution prevents it.

      Greets
      Jazzco

      1 Reply Last reply
      0
      • P Offline
        P Offline
        patrickkidd
        wrote on last edited by
        #3

        Nuts. So it sounds like I am already achieving #2, and for #1 I need to run the UIC code to build the form and then remove and then re-insert the first widget in the splitter?

        https://alaskafamilysystems.com/

        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