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. How to properly layout this form
QtWS25 Last Chance

How to properly layout this form

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 562 Views
  • 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
    PsylumDan
    wrote on last edited by
    #1

    In the first image the layout is good. But this the size in Qt Designer. The second image is this window maximized. You can see that the text in the upper portion has gained height. The widget on the bottom left is a label that will hold a pixmap. The two stacked widgets on the right are QChartViews. What I want is, when the window is maximized, the image label and the charts to increase in size and the text at the top to stay the same. I've tried grouping them together in sections and grid layouts. Nothing I do makes it do what I want it to do. Could I get some advice?

    ![alt text](0_1557326169047_1.PNG image url)
    0_1557326180655_2.PNG

    Gojir4G 1 Reply Last reply
    0
    • P PsylumDan

      In the first image the layout is good. But this the size in Qt Designer. The second image is this window maximized. You can see that the text in the upper portion has gained height. The widget on the bottom left is a label that will hold a pixmap. The two stacked widgets on the right are QChartViews. What I want is, when the window is maximized, the image label and the charts to increase in size and the text at the top to stay the same. I've tried grouping them together in sections and grid layouts. Nothing I do makes it do what I want it to do. Could I get some advice?

      ![alt text](0_1557326169047_1.PNG image url)
      0_1557326180655_2.PNG

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by Gojir4
      #2

      Hi @PsylumDan,

      You need to put stretch factor to 1 for your bottom part, so it will grow instead of your text.

      With QBoxLayout, you can do that using the second argument of QBoxLayout::addWidget or QBoxLayout::addLayout
      With QGridLayout, you can set stretch by row using QGridLayout::setRowStretch

      1 Reply Last reply
      2
      • P Offline
        P Offline
        PsylumDan
        wrote on last edited by
        #3

        Thanks for the quick reply. I'm doing this in the Qt Designer. Should I be doing it with code instead?

        Gojir4G mrjjM 2 Replies Last reply
        0
        • P PsylumDan

          Thanks for the quick reply. I'm doing this in the Qt Designer. Should I be doing it with code instead?

          Gojir4G Offline
          Gojir4G Offline
          Gojir4
          wrote on last edited by
          #4

          @PsylumDan Hum Ok,

          No, you can do it by clicking on the root widget containing your layout. Then go at bottom of the properties editor, you can see a section Layout, here you can change the layoutStretch property of each widget.
          Example with 2 widgets, by default you have 0,0, you can put 0,1 to set the last widget having the "growing priority".

          Sorry it could be simple with a picture. But I cannot post them because of proxy.

          1 Reply Last reply
          3
          • P PsylumDan

            Thanks for the quick reply. I'm doing this in the Qt Designer. Should I be doing it with code instead?

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

            @PsylumDan
            Hi
            You can also do it in Designer.
            alt text

            here told it that to top one should use 2/3 and last should use 1/3
            of the space.

            1 Reply Last reply
            4
            • P Offline
              P Offline
              PsylumDan
              wrote on last edited by
              #6

              Thanks guys. With ya'lls help I got it working as expected.

              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