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. Dynamic grid layout with splitters
QtWS25 Last Chance

Dynamic grid layout with splitters

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsplittergrid
12 Posts 5 Posters 6.5k 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
    Joel Bodenmann
    wrote on 27 May 2016, 12:11 last edited by Joel Bodenmann
    #1

    I have the need for a widget (that I will be using as the central widget of a QMainWindow) that allows me to drag-n-drop other widgets into it and arrange them in a grid layout. However, the sizes of the grid cells must be dynamic (like with a QSplitter where you can resize the cells) and I need the ability to merge cells (like in a spreadsheet where you make a big cell or multiple smaller ones). Basically I want to give the user the ability to create a layout like this by only drag-n-drop interactions (each blue rectangle is a QWidget):

    Right now I am at the point where each of the widgets (the blue rectangles in the figure above) emit a signal that informs the received (the SplitArea widget that I am trying to write) on which side of the widget (using Qt::Edge) a new widget should be added.

    Is there anything that Qt gives me that I can use to simplify this task? The only Idea I have right now is to write a SplitArea widget that maintains a list of many QSplitters and doing a lot of if- and switch-statements to arrange the objects. Should I even use QSplitters for this or better implement a custom QLayout class and somehow apply magic that allows to resize the layout by dragging the borders between the cells?

    I am thankful for any kind of suggestion on how to properly implement something like this.

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    R 1 Reply Last reply 27 May 2016, 12:57
    0
    • J Joel Bodenmann
      27 May 2016, 12:11

      I have the need for a widget (that I will be using as the central widget of a QMainWindow) that allows me to drag-n-drop other widgets into it and arrange them in a grid layout. However, the sizes of the grid cells must be dynamic (like with a QSplitter where you can resize the cells) and I need the ability to merge cells (like in a spreadsheet where you make a big cell or multiple smaller ones). Basically I want to give the user the ability to create a layout like this by only drag-n-drop interactions (each blue rectangle is a QWidget):

      Right now I am at the point where each of the widgets (the blue rectangles in the figure above) emit a signal that informs the received (the SplitArea widget that I am trying to write) on which side of the widget (using Qt::Edge) a new widget should be added.

      Is there anything that Qt gives me that I can use to simplify this task? The only Idea I have right now is to write a SplitArea widget that maintains a list of many QSplitters and doing a lot of if- and switch-statements to arrange the objects. Should I even use QSplitters for this or better implement a custom QLayout class and somehow apply magic that allows to resize the layout by dragging the borders between the cells?

      I am thankful for any kind of suggestion on how to properly implement something like this.

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 27 May 2016, 12:57 last edited by
      #2

      @Joel-Bodenmann
      if i got you correctly QMainWindow with QDockWidgets is really close to what you want to achieve

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      J 1 Reply Last reply 27 May 2016, 13:01
      0
      • R raven-worx
        27 May 2016, 12:57

        @Joel-Bodenmann
        if i got you correctly QMainWindow with QDockWidgets is really close to what you want to achieve

        J Offline
        J Offline
        Joel Bodenmann
        wrote on 27 May 2016, 13:01 last edited by
        #3

        @raven-worx Not at all. the QMainWindow only allows me to put but one "row" of widgets around the central widgets. My goal is to have a widget that arranges any number of widgets in any pattern as shown in my diagram, not just one row around a central widget.

        Also I want that to become the central widget of my main window. I am already using the dock widgets for other stuff ;)

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        R 1 Reply Last reply 27 May 2016, 13:06
        0
        • J Joel Bodenmann
          27 May 2016, 13:01

          @raven-worx Not at all. the QMainWindow only allows me to put but one "row" of widgets around the central widgets. My goal is to have a widget that arranges any number of widgets in any pattern as shown in my diagram, not just one row around a central widget.

          Also I want that to become the central widget of my main window. I am already using the dock widgets for other stuff ;)

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 27 May 2016, 13:06 last edited by
          #4

          @Joel-Bodenmann
          ok.
          I am afraid there is no (standard) ready Qt-provided solution for you.
          Either you look for a 3rd party implementation or do it yourself. But i guess that it will be a lot of work.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          J 1 Reply Last reply 27 May 2016, 13:58
          0
          • R raven-worx
            27 May 2016, 13:06

            @Joel-Bodenmann
            ok.
            I am afraid there is no (standard) ready Qt-provided solution for you.
            Either you look for a 3rd party implementation or do it yourself. But i guess that it will be a lot of work.

            J Offline
            J Offline
            Joel Bodenmann
            wrote on 27 May 2016, 13:58 last edited by
            #5

            Thank you for your help, I appreciate it.
            This will indeed result in a few nights worth of coding :P

            Industrial process automation software: https://simulton.com
            Embedded Graphics & GUI library: https://ugfx.io

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qtProgrammer
              wrote on 31 Oct 2016, 19:11 last edited by
              #6

              Hello @Joel-Bodenmann ,

              I am interested in your idea, did you ahieve what you wanted.?
              If so, did you use QSplitters.?

              J 1 Reply Last reply 3 Nov 2016, 21:47
              0
              • Q qtProgrammer
                31 Oct 2016, 19:11

                Hello @Joel-Bodenmann ,

                I am interested in your idea, did you ahieve what you wanted.?
                If so, did you use QSplitters.?

                J Offline
                J Offline
                Joel Bodenmann
                wrote on 3 Nov 2016, 21:47 last edited by Joel Bodenmann 11 Mar 2016, 21:52
                #7

                @qtProgrammer Please excuse the late reply...

                Yes I managed to get something up and running. It's a basic tiling window manager that uses QSplitter. What I have so far is working. You can put any QWidget at any place and resize the tiles with the mouse. However, drag'n'drop is not even close to finished.
                As it's far from finished and not really well tested I decided not to share it. It's currently collecting dust sitting on my SSD.

                ScreenShot

                Industrial process automation software: https://simulton.com
                Embedded Graphics & GUI library: https://ugfx.io

                R 1 Reply Last reply 25 Oct 2022, 17:06
                2
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 4 Nov 2016, 09:56 last edited by
                  #8

                  Hi
                  Even if not finished, it would still be super sample of how to use splitters in a clever way :)

                  1 Reply Last reply
                  2
                  • Q Offline
                    Q Offline
                    qtProgrammer
                    wrote on 4 Nov 2016, 20:10 last edited by
                    #9

                    I'd be interested in that example as well,
                    I heard people saying that Splitter is not an alternate to layout but just a container. But a layout is nothing but a container with some nice control over how widgets are laid out. Why not splitter have the same advantage.? After trying to find more info on QSplitter, i can say that there's not much available except the surface level documenation.

                    1 Reply Last reply
                    0
                    • J Joel Bodenmann
                      3 Nov 2016, 21:47

                      @qtProgrammer Please excuse the late reply...

                      Yes I managed to get something up and running. It's a basic tiling window manager that uses QSplitter. What I have so far is working. You can put any QWidget at any place and resize the tiles with the mouse. However, drag'n'drop is not even close to finished.
                      As it's far from finished and not really well tested I decided not to share it. It's currently collecting dust sitting on my SSD.

                      ScreenShot

                      R Offline
                      R Offline
                      russQt
                      wrote on 25 Oct 2022, 17:06 last edited by
                      #10

                      @Joel-Bodenmann Hi Joel, however unlikely as it may be, do you still have access to any of this code? Very curious how you implemented splitters inside the QGridLayout. If I understand correctly, you were able to drag widgets in order to expand/de-expand them using the QSplitters?

                      J 1 Reply Last reply 31 Oct 2022, 13:52
                      0
                      • R russQt
                        25 Oct 2022, 17:06

                        @Joel-Bodenmann Hi Joel, however unlikely as it may be, do you still have access to any of this code? Very curious how you implemented splitters inside the QGridLayout. If I understand correctly, you were able to drag widgets in order to expand/de-expand them using the QSplitters?

                        J Offline
                        J Offline
                        Joel Bodenmann
                        wrote on 31 Oct 2022, 13:52 last edited by
                        #11

                        @russQt Well, this has been a long time ago... :D

                        I definitely had this working - I used it with at least some success back then.
                        Unfortunately, I did throw this code/project out last year when performing some housekeeping (getting rid of old stuff).

                        I might still have it around on an old laptop. I'll check in the next few days and report back. But please don't keep your hopes up. Chances are slim.

                        Industrial process automation software: https://simulton.com
                        Embedded Graphics & GUI library: https://ugfx.io

                        1 Reply Last reply
                        1
                        • J Offline
                          J Offline
                          Joel Bodenmann
                          wrote on 16 Nov 2022, 14:57 last edited by
                          #12

                          @russQt I was digging hard but unfortunately I have no positive news for you. Sorry about that.

                          Industrial process automation software: https://simulton.com
                          Embedded Graphics & GUI library: https://ugfx.io

                          1 Reply Last reply
                          1
                          • A aemerzel referenced this topic on 3 Nov 2023, 19:50

                          • Login

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