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 manage GUI and Widgets while screen minimize and maximize in QT with layouts

How to manage GUI and Widgets while screen minimize and maximize in QT with layouts

Scheduled Pinned Locked Moved General and Desktop
qt designerqt development
10 Posts 2 Posters 9.3k 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.
  • J Offline
    J Offline
    John R
    wrote on last edited by
    #1

    Hello,

    I want to make my GUI and its widgets to be expanded and minimized fit to the
    screen size when user clicks on maximize and restore down(minimize). This is
    pretty basic!! For this I have put all my widgets and containers in
    a horizontal layout and run the preview. I thought like if I put all my
    widgets inside any qt layout control, it will display fit to any
    screen user clicks for min and max sizes but it went wrong somewhere

    When I put the different layouts around the GUI widgets, and while I
    maximize the window the right GUI part is displayed as empty, how to
    avoid this issue. When it maximize the GUI and widgets in the layout
    and containers should also be enlarged its size, then why it is happening?
    did I miss any settings anywhere? could anyone please help me?

    S 1 Reply Last reply
    0
    • J John R

      Hello,

      I want to make my GUI and its widgets to be expanded and minimized fit to the
      screen size when user clicks on maximize and restore down(minimize). This is
      pretty basic!! For this I have put all my widgets and containers in
      a horizontal layout and run the preview. I thought like if I put all my
      widgets inside any qt layout control, it will display fit to any
      screen user clicks for min and max sizes but it went wrong somewhere

      When I put the different layouts around the GUI widgets, and while I
      maximize the window the right GUI part is displayed as empty, how to
      avoid this issue. When it maximize the GUI and widgets in the layout
      and containers should also be enlarged its size, then why it is happening?
      did I miss any settings anywhere? could anyone please help me?

      S Offline
      S Offline
      SysTech
      wrote on last edited by SysTech
      #2

      @John-R

      It is possible to do what I think you are asking to do. I have several dialogs in my app that contract to a minimum size but also expand to the screen size. When either is done I have layouts that have minimum but no maximum size so they expand.

      It sounds to me like you have found your own issue, something is wrong some where. I realize this doesn't help you but it is most likely the issue. Somewhere you have a layout in place that is not expanding. Or you have some property set on some layout or layouts that do not allow them to expand.

      The layouts have control over how they change size. Look carefully at the options when you highlight your layout in the designer. I'm not in front of Qt Creator right now to give you the property name but it is pretty obvious.

      I'm not sure how far along your current windows is but in learning Qt Designer I had to do a few restarts to get the layout working as I wanted. The easiest way I found to do this (and some one else may have a much better way) is to cut and paste my current controls into a new layout that I can slide around on the screen. Then I pushed them pretty far to the lower right.

      Next I began to re-create my layout with nothing more than the layouts I needed and made sure they would resize as I desired. Then I went back and cut and pasted my various controls back in and removed the original layouts.

      If you have access to PluralSight training there is a reasonably good course on there by Todd Gentile that goes through setting up a layout for a controller and he teaches a small amount about how to setup layouts. But he doesn't go the distance of making his dialog work at full screen.

      Best of luck!

      J 1 Reply Last reply
      0
      • S SysTech

        @John-R

        It is possible to do what I think you are asking to do. I have several dialogs in my app that contract to a minimum size but also expand to the screen size. When either is done I have layouts that have minimum but no maximum size so they expand.

        It sounds to me like you have found your own issue, something is wrong some where. I realize this doesn't help you but it is most likely the issue. Somewhere you have a layout in place that is not expanding. Or you have some property set on some layout or layouts that do not allow them to expand.

        The layouts have control over how they change size. Look carefully at the options when you highlight your layout in the designer. I'm not in front of Qt Creator right now to give you the property name but it is pretty obvious.

        I'm not sure how far along your current windows is but in learning Qt Designer I had to do a few restarts to get the layout working as I wanted. The easiest way I found to do this (and some one else may have a much better way) is to cut and paste my current controls into a new layout that I can slide around on the screen. Then I pushed them pretty far to the lower right.

        Next I began to re-create my layout with nothing more than the layouts I needed and made sure they would resize as I desired. Then I went back and cut and pasted my various controls back in and removed the original layouts.

        If you have access to PluralSight training there is a reasonably good course on there by Todd Gentile that goes through setting up a layout for a controller and he teaches a small amount about how to setup layouts. But he doesn't go the distance of making his dialog work at full screen.

        Best of luck!

        J Offline
        J Offline
        John R
        wrote on last edited by
        #3

        @SysTech,

        Thank you very much for responding, it is very useful to me.

        I have lot of widgets in my form like number push buttons and input widgets kept in different tabs. As you instructed if I cut and paste these widgets into this layout, it is difficult to manage its widget positions once after putting into the layout.Also I have already observed the property editor parameters like layout margin, row stretching, and size constraints etc, but it is not quickly showing the output of these value settings in the GUI.

        I think, One example GUI .ui file with few number of widgets and properly managed the layout properties will solve my issue quickly, otherwise it will end up with eating lot of time. If you can kindly post any such small .ui example file, would be great help to deal this problem.

        S 1 Reply Last reply
        0
        • J John R

          @SysTech,

          Thank you very much for responding, it is very useful to me.

          I have lot of widgets in my form like number push buttons and input widgets kept in different tabs. As you instructed if I cut and paste these widgets into this layout, it is difficult to manage its widget positions once after putting into the layout.Also I have already observed the property editor parameters like layout margin, row stretching, and size constraints etc, but it is not quickly showing the output of these value settings in the GUI.

          I think, One example GUI .ui file with few number of widgets and properly managed the layout properties will solve my issue quickly, otherwise it will end up with eating lot of time. If you can kindly post any such small .ui example file, would be great help to deal this problem.

          S Offline
          S Offline
          SysTech
          wrote on last edited by
          #4

          @John-R

          John, rather than try to upload a UI file to you (if this doesn't work I will) try this:

          Create a new project, Qt Widgets project.
          After the project is created open the .ui file so it shows in the creator.

          Find "Horizontal Layout". Drag this on to your form. It will show as a red outline.

          Now right-click OUTSIDE of the read outline. Select "Layout" at the bottom then select "Layout Horizontally".

          The red outline for the Horizontal Layout will now fill your window.

          Now just drag a bunch of push buttons in and they will align horizontally.

          Now if you resize the form you'll see that the push buttons expand or contract to fill the layout.

          This sequence illustrates the general idea I think you are after. So if you then built your UI inside of this horizontal layout it would expand just as the buttons do in this simple example.

          Let me know if this helps.

          J 2 Replies Last reply
          1
          • S SysTech

            @John-R

            John, rather than try to upload a UI file to you (if this doesn't work I will) try this:

            Create a new project, Qt Widgets project.
            After the project is created open the .ui file so it shows in the creator.

            Find "Horizontal Layout". Drag this on to your form. It will show as a red outline.

            Now right-click OUTSIDE of the read outline. Select "Layout" at the bottom then select "Layout Horizontally".

            The red outline for the Horizontal Layout will now fill your window.

            Now just drag a bunch of push buttons in and they will align horizontally.

            Now if you resize the form you'll see that the push buttons expand or contract to fill the layout.

            This sequence illustrates the general idea I think you are after. So if you then built your UI inside of this horizontal layout it would expand just as the buttons do in this simple example.

            Let me know if this helps.

            J Offline
            J Offline
            John R
            wrote on last edited by
            #5

            @SysTech ,

            Things are pretty well with push buttons and line edit widgets,

            but I am struggling with applying same method to control for the layout management with other large number of different qt widgets inside Tabs and other containers, then I feel it is not as easy as with mere buttons and Line edit. Any way thanks a lot for make me understand at least the concept, you help is really helpful but still I may need your help for some time more on the same thread since I couldn't make my result as I desired.

            My present issue is 20 buttons and 8 other type of widgets inside 2 different tabs and tried with grid layout but it changes the size and style of buttons according to layout setting, so it display now ugly. After putting it we won’t get any control to change the size and style as previous so it doesn't look good, but it expands and contracts well, that is great.

            1 Reply Last reply
            0
            • S SysTech

              @John-R

              John, rather than try to upload a UI file to you (if this doesn't work I will) try this:

              Create a new project, Qt Widgets project.
              After the project is created open the .ui file so it shows in the creator.

              Find "Horizontal Layout". Drag this on to your form. It will show as a red outline.

              Now right-click OUTSIDE of the read outline. Select "Layout" at the bottom then select "Layout Horizontally".

              The red outline for the Horizontal Layout will now fill your window.

              Now just drag a bunch of push buttons in and they will align horizontally.

              Now if you resize the form you'll see that the push buttons expand or contract to fill the layout.

              This sequence illustrates the general idea I think you are after. So if you then built your UI inside of this horizontal layout it would expand just as the buttons do in this simple example.

              Let me know if this helps.

              J Offline
              J Offline
              John R
              wrote on last edited by
              #6

              @SysTech,

              Thanks a lot for helping, it works well with push buttons but when I design with tabs and adding big number of widgets, I am constantly failing to develop a standard layout, frustrating...somebody should write a blog on this topic with some example with a complex GUI design.

              I applied grid layout to tab first and after I applied same grid layout to form, then all the widgets inside the tab become ugly..

              is it possible to make individual widgets layout setting?

              Like, some widget needs to be expanded with resizing and some widgets should not be expanded, those has to be always static with its size and style, is it possible? I searched absolute positing in property editor but nothing found!!

              S 1 Reply Last reply
              0
              • J John R

                @SysTech,

                Thanks a lot for helping, it works well with push buttons but when I design with tabs and adding big number of widgets, I am constantly failing to develop a standard layout, frustrating...somebody should write a blog on this topic with some example with a complex GUI design.

                I applied grid layout to tab first and after I applied same grid layout to form, then all the widgets inside the tab become ugly..

                is it possible to make individual widgets layout setting?

                Like, some widget needs to be expanded with resizing and some widgets should not be expanded, those has to be always static with its size and style, is it possible? I searched absolute positing in property editor but nothing found!!

                S Offline
                S Offline
                SysTech
                wrote on last edited by
                #7

                @John-R

                Hi John, I think that making a perfectly expandable/contractable view with a lot of complex items will always be difficult. I do agree that in some ways I've struggled myself to get Qt to lay things out the way I want.

                Without seeing what you are trying to do it is hard to provide any suggestions.

                In the past (in C++ but not under the Qt framework) I ran into enough issues with this same basic thing that I ended up doing it in code. IE I trapped the form resize event and wrote code to decide based on some different sizes how to move things around on the form.

                I will say this: Qt Creator is written in Qt itself. You can download the code for Qt creator and perhaps if you looked at how they were doing things it might help. I am not sure if they are doing layout with widgets or QML or what but the Qt Gui is pretty nice and could serve as a guide for what is possible.

                J 1 Reply Last reply
                0
                • S SysTech

                  @John-R

                  Hi John, I think that making a perfectly expandable/contractable view with a lot of complex items will always be difficult. I do agree that in some ways I've struggled myself to get Qt to lay things out the way I want.

                  Without seeing what you are trying to do it is hard to provide any suggestions.

                  In the past (in C++ but not under the Qt framework) I ran into enough issues with this same basic thing that I ended up doing it in code. IE I trapped the form resize event and wrote code to decide based on some different sizes how to move things around on the form.

                  I will say this: Qt Creator is written in Qt itself. You can download the code for Qt creator and perhaps if you looked at how they were doing things it might help. I am not sure if they are doing layout with widgets or QML or what but the Qt Gui is pretty nice and could serve as a guide for what is possible.

                  J Offline
                  J Offline
                  John R
                  wrote on last edited by
                  #8

                  @SysTech,

                  Thanks a lot dude,I feel, I am slowly slowly getting familiar and confident on this layout making. Your help was the first breakthrough!!

                  S 1 Reply Last reply
                  0
                  • J John R

                    @SysTech,

                    Thanks a lot dude,I feel, I am slowly slowly getting familiar and confident on this layout making. Your help was the first breakthrough!!

                    S Offline
                    S Offline
                    SysTech
                    wrote on last edited by
                    #9

                    @John-R

                    You are most welcome. With anything there is always that initial learning curve. Once you get past it things start to feel more familiar and better.

                    I did lots of programming in C++ builder. In that framework and IDE to implement code behind a button say you just double clicked the button.

                    Here in Qt you have to select a slot. Same general idea but implemented just a little differently. Just different enough that the C++ builder guy/gal spends a little more time wondering how to do things.

                    But once you get it a few times then it starts to lock in.

                    J 1 Reply Last reply
                    0
                    • S SysTech

                      @John-R

                      You are most welcome. With anything there is always that initial learning curve. Once you get past it things start to feel more familiar and better.

                      I did lots of programming in C++ builder. In that framework and IDE to implement code behind a button say you just double clicked the button.

                      Here in Qt you have to select a slot. Same general idea but implemented just a little differently. Just different enough that the C++ builder guy/gal spends a little more time wondering how to do things.

                      But once you get it a few times then it starts to lock in.

                      J Offline
                      J Offline
                      John R
                      wrote on last edited by
                      #10

                      @SysTech,

                      Yes you are saying right...

                      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