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. I can't set layout position
QtWS25 Last Chance

I can't set layout position

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 2.4k 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.
  • H Offline
    H Offline
    hernancrespo89
    wrote on last edited by
    #1

    Hi everyone, i am new with PyQt, i am using QtDesigner
    i created a Horizonal Layout, then i add a button to this layout.
    Untitled.png

    When i run the code, i see that button is on the middle of GUI. Why does it happen? Why i don't see button on the position i set?

    Untitled2.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Because you don't position a layout. The layout is set on the widget and then manages whatever you put in it following the rules of the layout type you are using.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Because you don't position a layout. The layout is set on the widget and then manages whatever you put in it following the rules of the layout type you are using.

        H Offline
        H Offline
        hernancrespo89
        wrote on last edited by
        #3

        @SGaist said in I can't set layout position:

        Hi,

        Because you don't position a layout. The layout is set on the widget and then manages whatever you put in it following the rules of the layout type you are using.

        Thanks for reply,
        I dont want to change positiont of button. Also i need to put button to a layout. Which layout type should i choose?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why do you want your button inside a layout since you don't want the behaviour offered by the layout ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 1 Reply Last reply
          0
          • SGaistS SGaist

            Why do you want your button inside a layout since you don't want the behaviour offered by the layout ?

            H Offline
            H Offline
            hernancrespo89
            wrote on last edited by
            #5

            @SGaist Actually i tried to simply my problem with button. Here is the my original problem.
            Untitled3.png

            As you see, i have two frames and one frame (frame3) outside two frames. When i click set Lay Out in a Grid, frame1 disappears and when i maximize window. Size of widgests don't change. (sizePolicies are expanding)
            This link is my referece (11:40)

            Pl45m4P 1 Reply Last reply
            0
            • H hernancrespo89

              @SGaist Actually i tried to simply my problem with button. Here is the my original problem.
              Untitled3.png

              As you see, i have two frames and one frame (frame3) outside two frames. When i click set Lay Out in a Grid, frame1 disappears and when i maximize window. Size of widgests don't change. (sizePolicies are expanding)
              This link is my referece (11:40)

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by Pl45m4
              #6

              @hernancrespo89

              So you want the same behavior as in the video?!
              What layouts did you set so far?
              I dont believe that frame1 disappears, I guess it just shrinks due to expanding frame2.

              Btw: You can combine multiple layouts and layout types until you get, what you want to achieve. A GridLayout is not always the best solution. Especially if you want to have your button (optional: some spacers) your frame, which has its own inner layout, in one layout.

              I made an example layout structure for another issue. Maybe it helps.
              Here


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              H 1 Reply Last reply
              1
              • Pl45m4P Pl45m4

                @hernancrespo89

                So you want the same behavior as in the video?!
                What layouts did you set so far?
                I dont believe that frame1 disappears, I guess it just shrinks due to expanding frame2.

                Btw: You can combine multiple layouts and layout types until you get, what you want to achieve. A GridLayout is not always the best solution. Especially if you want to have your button (optional: some spacers) your frame, which has its own inner layout, in one layout.

                I made an example layout structure for another issue. Maybe it helps.
                Here

                H Offline
                H Offline
                hernancrespo89
                wrote on last edited by
                #7

                @Pl45m4
                Thx. I have looked that post. And I have tried to implement it. Firstly, I added button and horizontal spaces into a horizontal layout. And I set sizePolicy to expanding but when i click maximize layout doesn't expand
                Untitled.png

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Frame 2: 2 QVBoxLayouts and 1 QHBoxLayout. Or one QGridLayout

                  Frame 1: it's not really clear what's inside of it.

                  Frame 3: One QGridLayout and the button in a QHBoxLayout, and you add a stretch after the button.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  H 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Frame 2: 2 QVBoxLayouts and 1 QHBoxLayout. Or one QGridLayout

                    Frame 1: it's not really clear what's inside of it.

                    Frame 3: One QGridLayout and the button in a QHBoxLayout, and you add a stretch after the button.

                    H Offline
                    H Offline
                    hernancrespo89
                    wrote on last edited by
                    #9

                    @SGaist said in I can't set layout position:

                    Frame 1: it's not really clear what's inside of it.

                    It is a label.

                    Frame 2: 2 QVBoxLayouts and 1 QHBoxLayout. Or one QGridLayout

                    I thought 2 QVBoxLayout. But when I put Widget to a layout I can't set its size, so I am confused. Which widgets should I put to QHBoxLayout

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Please take the time to learn about the use of layouts.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved