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. Formatting Object in Form Layout
Forum Update on Monday, May 27th 2025

Formatting Object in Form Layout

Scheduled Pinned Locked Moved Unsolved General and Desktop
35 Posts 3 Posters 4.2k 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.
  • M Offline
    M Offline
    mzimmers
    wrote on 20 May 2019, 17:52 last edited by mzimmers
    #1

    Hi all -

    I'm trying to use a form layout to organize several details in a widget. Most of the details are line text items, but one is another widget that looks like this:
    0_1558374566578_ipconfig.PNG

    (I had to use the stylesheet to set the background to white.)

    When it displays in my form, here's what it looks like:0_1558374606517_is.PNG

    The spacing isn't right, and it looks like something is misaligned vertically. Plus I'd like to have a black border (I could add that to the style sheet, I suppose).

    Can someone advise on how to properly space an object within the layout? Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 May 2019, 20:42 last edited by
      #2

      Hi,

      How do you build that assignment source widget ?

      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
      0
      • M Offline
        M Offline
        mzimmers
        wrote on 20 May 2019, 20:55 last edited by
        #3

        Massive brain failure here. My other post about the cross headers was meant as a reply here.

        As stated, I create the IpSource object in Designer, and use it in another Widget (also created in Designer). Not sure if this answers your question...

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 20 May 2019, 20:57 last edited by
          #4

          Partially, I'm thinking about using a QFrame to contain the checkboxes. That might give you the visual you are looking for.

          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
          0
          • M Offline
            M Offline
            mzimmers
            wrote on 20 May 2019, 21:10 last edited by
            #5

            Would the QFrame be instead of the QGroupBox I'm currently using?

            K 1 Reply Last reply 20 May 2019, 21:34
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 20 May 2019, 21:14 last edited by
              #6

              That's what I had mind yes.

              Basically:

              • QFrame
              • QVBoxLayout
              • QRadioButton

              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
              0
              • M mzimmers
                20 May 2019, 21:10

                Would the QFrame be instead of the QGroupBox I'm currently using?

                K Offline
                K Offline
                kshegunov
                Moderators
                wrote on 20 May 2019, 21:34 last edited by
                #7

                Your widget doesn't have a layout. It contains a layout, but it itself doesn't have one.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mzimmers
                  wrote on 20 May 2019, 21:38 last edited by
                  #8

                  I assume you're talking about the top-level widget. Does not having a top-level layout contribute to the problem I'm experiencing?

                  K 1 Reply Last reply 20 May 2019, 21:41
                  0
                  • M mzimmers
                    20 May 2019, 21:38

                    I assume you're talking about the top-level widget. Does not having a top-level layout contribute to the problem I'm experiencing?

                    K Offline
                    K Offline
                    kshegunov
                    Moderators
                    wrote on 20 May 2019, 21:41 last edited by
                    #9

                    @mzimmers said in Formatting Object in Form Layout:

                    I assume you're talking about the top-level widget.

                    No, I'm talking about the small widget you're inserting into the top-level widget.
                    But the consideration applies to the top level widget as well, if it doesn't have a layout, give it one.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mzimmers
                      wrote on 20 May 2019, 22:28 last edited by mzimmers
                      #10

                      Trying to consolidate kshugunov's suggestion with SGaist's...I created a QFrame, QVBoxLayout, and two QRadioButtons. Oddly enough, when I don't use a form layout on my details, the information shows up (though it's not yet formatted as I'd like):

                      0_1558391256508_good.PNG

                      But when I do a form layout on the stuff on the left, The frame shrinks and the buttons disappear:

                      0_1558391299115_bad.PNG

                      Do I need some explicit geometry on the frame to prevent it from getting shrunk?

                      K 1 Reply Last reply 21 May 2019, 08:03
                      0
                      • M mzimmers
                        20 May 2019, 22:28

                        Trying to consolidate kshugunov's suggestion with SGaist's...I created a QFrame, QVBoxLayout, and two QRadioButtons. Oddly enough, when I don't use a form layout on my details, the information shows up (though it's not yet formatted as I'd like):

                        0_1558391256508_good.PNG

                        But when I do a form layout on the stuff on the left, The frame shrinks and the buttons disappear:

                        0_1558391299115_bad.PNG

                        Do I need some explicit geometry on the frame to prevent it from getting shrunk?

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 21 May 2019, 08:03 last edited by
                        #11

                        @mzimmers said in Formatting Object in Form Layout:

                        Do I need some explicit geometry on the frame to prevent it from getting shrunk?

                        Mind uploading the .ui file somewhere so I can open it with the designer?

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mzimmers
                          wrote on 21 May 2019, 13:45 last edited by
                          #12

                          editdialog.ui

                          Thanks...

                          K 1 Reply Last reply 21 May 2019, 16:12
                          0
                          • M mzimmers
                            21 May 2019, 13:45

                            editdialog.ui

                            Thanks...

                            K Offline
                            K Offline
                            kshegunov
                            Moderators
                            wrote on 21 May 2019, 16:12 last edited by
                            #13

                            Look here. It just is getting used to the layout system is all. And give your widgets layouts, so they can put their child widgets correctly.

                            Read and abide by the Qt Code of Conduct

                            1 Reply Last reply
                            2
                            • M Offline
                              M Offline
                              mzimmers
                              wrote on 21 May 2019, 18:34 last edited by
                              #14

                              Thanks for taking the time to do that, kshegunov. So, I guess the takeaway is that pretty much everything needs layouts? I'd been limiting my use of them to where I could see they were needed, but if failing to use them results in stuff (like my radio buttons) not showing up, then I guess they're needed in more places than are immediately evident.

                              K 1 Reply Last reply 21 May 2019, 19:05
                              0
                              • M mzimmers
                                21 May 2019, 18:34

                                Thanks for taking the time to do that, kshegunov. So, I guess the takeaway is that pretty much everything needs layouts? I'd been limiting my use of them to where I could see they were needed, but if failing to use them results in stuff (like my radio buttons) not showing up, then I guess they're needed in more places than are immediately evident.

                                K Offline
                                K Offline
                                kshegunov
                                Moderators
                                wrote on 21 May 2019, 19:05 last edited by
                                #15

                                @mzimmers said in Formatting Object in Form Layout:

                                So, I guess the takeaway is that pretty much everything needs layouts?

                                Yes, pretty much. The widget depends on its layout to manage the geometry of the children, so if there's none the children float freely. Child layouts (the ones in red) are much more rarely needed, but the widgets have to have them to display properly.

                                Read and abide by the Qt Code of Conduct

                                1 Reply Last reply
                                1
                                • M Offline
                                  M Offline
                                  mzimmers
                                  wrote on 21 May 2019, 20:15 last edited by
                                  #16

                                  Makes sense. With the addition of some spacers, I was able to get the layout a little more to my liking.

                                  So, what's the verdict on my IP selector: should I be using a Frame or a QGroupBox?

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 21 May 2019, 20:20 last edited by
                                    #17

                                    Use whatever gets you the result you are looking for.

                                    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
                                    0
                                    • M Offline
                                      M Offline
                                      mzimmers
                                      wrote on 21 May 2019, 21:11 last edited by
                                      #18

                                      Right now, I'm experiencing the same spacing problem with either.
                                      0_1558473079665_space.PNG

                                      What might I be doing to create that large gap between the Device Name and the IP Assignment Source?

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on 21 May 2019, 21:23 last edited by
                                        #19

                                        Might be a silly question but do you have any empty row ?

                                        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
                                        0
                                        • M Offline
                                          M Offline
                                          mzimmers
                                          wrote on 21 May 2019, 21:28 last edited by
                                          #20

                                          No.

                                          0_1558474125044_design.PNG

                                          1 Reply Last reply
                                          0

                                          1/35

                                          20 May 2019, 17:52

                                          • Login

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