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. Layout - adjust size to its content
Forum Updated to NodeBB v4.3 + New Features

Layout - adjust size to its content

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 9.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.
  • N Offline
    N Offline
    NDev
    wrote on last edited by
    #1

    How can I force my layout to adjust its size as per the child widgets. What I have is a vertical layout on my QMainWidget. I am adding sub widgets to it based on some conditions. I need my vertical layout to shrink and expand based on the number of widgets I add to my vertical layout.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Darryl DSouza
      wrote on last edited by
      #2

      There is showcase for the same. See http://developer.qt.nokia.com/forums/viewthread/2766/

      Darryl D'Souza

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NDev
        wrote on last edited by
        #3

        I am not sure if that is what I need.. I saw the video, there the size of the layout is same and child widgets are adjusted to available space.

        What I am looking for is if my layout has two widget with 100 px by 100 px , by layout should adjust to size 100px by 200 px, and if I have three widget my layout should adjust to size 100px by 300 px

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You can do that, by making sure the widgets you put in that layout have a minimum size.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Darryl DSouza
            wrote on last edited by
            #5

            Use QDesktopWidget::screenGeometry to get the screen size and then you can decide based on the ratio you want for your widgets. You can then use QLayout::SetFixedSize in case you want the layout to be of exactly fixed size.

            Darryl D'Souza

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NDev
              wrote on last edited by
              #6

              I was hoping I can use the sizing policy for layout to get this. but it does not seems to work for me.

              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