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. Making QPushButtons span multiple columns in QGridLayout
Forum Updated to NodeBB v4.3 + New Features

Making QPushButtons span multiple columns in QGridLayout

Scheduled Pinned Locked Moved Solved General and Desktop
25 Posts 4 Posters 17.1k Views 2 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.
  • Q Qtstarter121

    @Gojir4 So in terms of adding a column, the only way I see that working is when I add another button to one of the rows at the end, then it auto-creates a column for every row( you can't just add extra columns only to one row). So let's say I do that anyway, for the last row I suppose then I could specify in the ui file a column span of 2 per button like I did previously in the <item ... >, but the for the other rows which only contain 3 buttons, the column span now has to change to 4/3 which again doesn't work...

    With regards to solution number 2, I'm thinking this might be the only viable solution to get this working inside Qt Designer. I would need to break my current layout, resize my buttons manually the way I want and then re-arrange them in a grid again ( if I understood you correctly).

    Q Offline
    Q Offline
    Qtstarter121
    wrote on last edited by
    #11

    @Qtstarter121 hmm so I tried breaking my existing layout, and in my row with only 2 buttons I tried resizing those two buttons, selected everything and re-arranged in a grid layout but unfortunately it still forces a third column to be created in the last row.

    1 Reply Last reply
    0
    • mrjjM mrjj

      Hi
      as mr @Christian-Ehrlicher says
      alt text

      Q Offline
      Q Offline
      Qtstarter121
      wrote on last edited by
      #12

      @mrjj I wasn't able to see the animation before for some reason. I'm going to try this and get back to you.

      1 Reply Last reply
      0
      • Q Qtstarter121

        @Gojir4 So in terms of adding a column, the only way I see that working is when I add another button to one of the rows at the end, then it auto-creates a column for every row( you can't just add extra columns only to one row). So let's say I do that anyway, for the last row I suppose then I could specify in the ui file a column span of 2 per button like I did previously in the <item ... >, but the for the other rows which only contain 3 buttons, the column span now has to change to 4/3 which again doesn't work...

        With regards to solution number 2, I'm thinking this might be the only viable solution to get this working inside Qt Designer. I would need to break my current layout, resize my buttons manually the way I want and then re-arrange them in a grid again ( if I understood you correctly).

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

        @Qtstarter121 said in Making QPushButtons span multiple columns in QGridLayout:

        @Gojir4 So in terms of adding a column, the only way I see that working is when I add another button to one of the rows at the end, then it auto-creates a column for every row( you can't just add extra columns only to one row). So let's say I do that anyway, for the last row I suppose then I could specify in the ui file a column span of 2 per button like I did previously in the <item ... >, but the for the other rows which only contain 3 buttons, the column span now has to change to 4/3 which again doesn't work...

        Is that possible to show us some drawing of what you are trying to achieve ? It will help a lot
        Is it something like that ? (sorry I cannot post image)

        ┌----┬-----┬----┐
        ├----┴--┬--┴----┤
        ├----┬--┴--┬----┤
        └----┴-----┴----┘
        

        @Qtstarter121 said in Making QPushButtons span multiple columns in QGridLayout:

        With regards to solution number 2, I'm thinking this might be the only viable solution to get this working inside Qt Designer. I would need to break my current layout, resize my buttons manually the way I want and then re-arrange them in a grid again ( if I understood you correctly).

        Yes that's what I meant. but it seems it didn't work according to your reply to yourself :)

        Q 1 Reply Last reply
        0
        • Gojir4G Gojir4

          @Qtstarter121 said in Making QPushButtons span multiple columns in QGridLayout:

          @Gojir4 So in terms of adding a column, the only way I see that working is when I add another button to one of the rows at the end, then it auto-creates a column for every row( you can't just add extra columns only to one row). So let's say I do that anyway, for the last row I suppose then I could specify in the ui file a column span of 2 per button like I did previously in the <item ... >, but the for the other rows which only contain 3 buttons, the column span now has to change to 4/3 which again doesn't work...

          Is that possible to show us some drawing of what you are trying to achieve ? It will help a lot
          Is it something like that ? (sorry I cannot post image)

          ┌----┬-----┬----┐
          ├----┴--┬--┴----┤
          ├----┬--┴--┬----┤
          └----┴-----┴----┘
          

          @Qtstarter121 said in Making QPushButtons span multiple columns in QGridLayout:

          With regards to solution number 2, I'm thinking this might be the only viable solution to get this working inside Qt Designer. I would need to break my current layout, resize my buttons manually the way I want and then re-arrange them in a grid again ( if I understood you correctly).

          Yes that's what I meant. but it seems it didn't work according to your reply to yourself :)

          Q Offline
          Q Offline
          Qtstarter121
          wrote on last edited by
          #14

          @Gojir4 I want something like this:

          0_1526390746422_Capture.PNG

          mrjjM Gojir4G 2 Replies Last reply
          0
          • Q Qtstarter121

            @Gojir4 I want something like this:

            0_1526390746422_Capture.PNG

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

            @Qtstarter121
            Hi
            You can use one of the red layouts from Layout section to the left. ( not right click)
            alt text

            Q 1 Reply Last reply
            2
            • Q Qtstarter121

              @Gojir4 I want something like this:

              0_1526390746422_Capture.PNG

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

              @Qtstarter121 What about that ? This is what I tried to explain in one of my previous post.

              alt text

              Sorry for quality of the gif, I'm not an expert in video conversion :)

              mrjjM Q 2 Replies Last reply
              2
              • Gojir4G Gojir4

                @Qtstarter121 What about that ? This is what I tried to explain in one of my previous post.

                alt text

                Sorry for quality of the gif, I'm not an expert in video conversion :)

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

                @Gojir4
                Cool. I didn't know it would just allow it!
                Ps. if u need gif anims, this just works
                http://www.screentogif.com/

                Gojir4G 1 Reply Last reply
                2
                • mrjjM mrjj

                  @Gojir4
                  Cool. I didn't know it would just allow it!
                  Ps. if u need gif anims, this just works
                  http://www.screentogif.com/

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

                  @mrjj Thanks for the tip.

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Qtstarter121
                    Hi
                    You can use one of the red layouts from Layout section to the left. ( not right click)
                    alt text

                    Q Offline
                    Q Offline
                    Qtstarter121
                    wrote on last edited by
                    #19

                    @mrjj I did that, instead of selecting all buttons and right click then layout in grid, I instead dragged a Grid Layout from the left panel and tried inputting buttons one by one into the layout, but once I finish the first row, the layout is fixed to define 3 columns, so I still can't only have 2 columns in the last row... there will always be that one column to the right that is empty.

                    0_1526397104546_Capture2.PNG

                    shaded region represents an empty cell that always exists no matter how I drag my buttons around.

                    mrjjM 1 Reply Last reply
                    0
                    • Q Qtstarter121

                      @mrjj I did that, instead of selecting all buttons and right click then layout in grid, I instead dragged a Grid Layout from the left panel and tried inputting buttons one by one into the layout, but once I finish the first row, the layout is fixed to define 3 columns, so I still can't only have 2 columns in the last row... there will always be that one column to the right that is empty.

                      0_1526397104546_Capture2.PNG

                      shaded region represents an empty cell that always exists no matter how I drag my buttons around.

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

                      @Qtstarter121
                      I i used both a GridLayout and a red layout i put as last row.
                      But it seems @Gojir4 made it do it without extra layout.
                      we just need him to tell what he clicks after selecting them all
                      as video is faster than my eye :)

                      Gojir4G 1 Reply Last reply
                      1
                      • Q Offline
                        Q Offline
                        Qtstarter121
                        wrote on last edited by
                        #21

                        I'm confused as to what a "red layout" is. Isn't selecting a Grid Layout from the left panel, and selecting all buttons and right click-> Layout > Layout in Grid the same thing?

                        1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @Qtstarter121
                          I i used both a GridLayout and a red layout i put as last row.
                          But it seems @Gojir4 made it do it without extra layout.
                          we just need him to tell what he clicks after selecting them all
                          as video is faster than my eye :)

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

                          @mrjj @Qtstarter121 I'm clicking on "Layout in a grid" :)
                          alt text

                          1 Reply Last reply
                          1
                          • Gojir4G Gojir4

                            @Qtstarter121 What about that ? This is what I tried to explain in one of my previous post.

                            alt text

                            Sorry for quality of the gif, I'm not an expert in video conversion :)

                            Q Offline
                            Q Offline
                            Qtstarter121
                            wrote on last edited by
                            #23

                            @Gojir4 I know this is a pretty late reply but I just wanted to say that this actually worked out for me. Thanks so much! The GIF animation was very helpful.

                            Gojir4G 1 Reply Last reply
                            0
                            • Q Qtstarter121

                              @Gojir4 I know this is a pretty late reply but I just wanted to say that this actually worked out for me. Thanks so much! The GIF animation was very helpful.

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

                              @Qtstarter121 Glad it helped !
                              Can you please set the thread as "Solved"
                              Thanks

                              1 Reply Last reply
                              0
                              • Q Offline
                                Q Offline
                                Qtstarter121
                                wrote on last edited by
                                #25

                                Sorry, I know it's like over a year later, but I have finally marked it as solved. Thanks for the help.

                                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