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. Line under radio Button and Button sizing in a Layout
Forum Updated to NodeBB v4.3 + New Features

Line under radio Button and Button sizing in a Layout

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 660 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.
  • D Offline
    D Offline
    Detzi
    wrote on 3 Apr 2021, 10:12 last edited by
    #1

    Hi there,
    i started to play around with QT Creator and put together a small GUI for a piece of Test software. I used the "design" functionality and "drag and drop" to create the project so far and i came across two points i seem not to be able to solve on my own.
    The first one is a very thin line appearing under one of the radio buttons which i don't know where it comes from and how to get rid of it.

    Bildschirmfoto von 2021-04-03 11-58-03.png

    The second one is that i cant resize the PushButtons in the lower right ("Start Test" / "Reset Config"), the option to change their size gets greyed out as soon as i put them into the layout box. How can i resize them? At last here is the head of my system info. I currently see no way to upload my whole project but i would if necessary.

    Qt 5.15.2 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.1 20160406 (Red Hat 5.3.1-6)) on "xcb" 
    OS: Ubuntu 20.04.2 LTS [linux version 5.8.0-48-generic]
    

    Thanks in advance for any assistance.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 3 Apr 2021, 10:47 last edited by mrjj 4 Mar 2021, 11:01
      #2

      Hi and welcome to the forums

      That strange line. Is it listed to the right in Design mode ?
      (there is a widget tree shown)
      It looks like a normal horzLine widget. but hard to say.

      When a widget is added to a layout, its size and location is handled by the layout.
      To affect its size, you can specify min and/or max size for the widget amoung other things.
      alt text

      So to resize your button, you can set its minimum size so the layout allows/follows this.
      https://doc.qt.io/qt-5/layout.html

      1 Reply Last reply
      1
      • D Offline
        D Offline
        Detzi
        wrote on 3 Apr 2021, 12:29 last edited by
        #3

        Hi @mrjj :)
        thank you for helping me out. I succeeded to change the "minimum height" of the Button , i could swear i searched there at least twice before but i must have overlooked it. Derpy me.
        The line does not appear in my Design tree, but i snipped it so you can have a look for yourself.
        Bildschirmfoto von 2021-04-03 14-22-15.png
        It is also only visible when i run/build the code.

        P 1 Reply Last reply 3 Apr 2021, 13:52
        0
        • D Detzi
          3 Apr 2021, 12:29

          Hi @mrjj :)
          thank you for helping me out. I succeeded to change the "minimum height" of the Button , i could swear i searched there at least twice before but i must have overlooked it. Derpy me.
          The line does not appear in my Design tree, but i snipped it so you can have a look for yourself.
          Bildschirmfoto von 2021-04-03 14-22-15.png
          It is also only visible when i run/build the code.

          P Online
          P Online
          Pl45m4
          wrote on 3 Apr 2021, 13:52 last edited by Pl45m4 4 Mar 2021, 13:53
          #4

          @Detzi

          Your centralWidget does not have any layout :) You should fix this to avoid further layout issues :)
          (Also both of your QGroupBoxes)

          Your layouts are inside your boxes but not applied to them.


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

          ~E. W. Dijkstra

          1 Reply Last reply
          2
          • D Offline
            D Offline
            Detzi
            wrote on 3 Apr 2021, 16:42 last edited by
            #5

            @Pl45m4 do you mean like this?
            Bildschirmfoto von 2021-04-03 18-38-56.png

            I think i figured out what the line is/was, it seems to be the border line of the RadioButton Box.

            P 1 Reply Last reply 3 Apr 2021, 17:38
            0
            • D Detzi
              3 Apr 2021, 16:42

              @Pl45m4 do you mean like this?
              Bildschirmfoto von 2021-04-03 18-38-56.png

              I think i figured out what the line is/was, it seems to be the border line of the RadioButton Box.

              P Online
              P Online
              Pl45m4
              wrote on 3 Apr 2021, 17:38 last edited by Pl45m4 4 Mar 2021, 17:42
              #6

              @Detzi

              Still no layout (as you can see from the red crossed signs next to your centralWidget and your two GroupBoxes).
              Delete the layouts inside these containers (verticalLayout_4, _5 and _6), assign a layout to them (Right-click -> Layout...) and add your content again.

              Edit:
              Actually you have to add content first, before you can assign a layout, so delete your verticalLayouts, put content back in and then assign a layout.


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

              ~E. W. Dijkstra

              1 Reply Last reply
              1
              • D Offline
                D Offline
                Detzi
                wrote on 4 Apr 2021, 06:19 last edited by
                #7

                @Pl45m4
                I think i got it this time
                Bildschirmfoto von 2021-04-04 08-12-24.png

                Although i don't understand how this is beneficial. I tried to read up why this is good practice here:
                Qt Documentation: Layout Management but it seems not to talk about this.
                Also for horizontalLayout_4 does it matter that it is a Layout container or should i rather use a group box and assign a Layout?

                P 1 Reply Last reply 4 Apr 2021, 15:25
                0
                • D Detzi
                  4 Apr 2021, 06:19

                  @Pl45m4
                  I think i got it this time
                  Bildschirmfoto von 2021-04-04 08-12-24.png

                  Although i don't understand how this is beneficial. I tried to read up why this is good practice here:
                  Qt Documentation: Layout Management but it seems not to talk about this.
                  Also for horizontalLayout_4 does it matter that it is a Layout container or should i rather use a group box and assign a Layout?

                  P Online
                  P Online
                  Pl45m4
                  wrote on 4 Apr 2021, 15:25 last edited by
                  #8

                  @Detzi said in Line under radio Button and Button sizing in a Layout:

                  should i rather use a group box and assign a Layout?

                  A standard layout should be enough.
                  You don't need QGroupBoxes frame and title functionality there.QGroupBox fits perfectly in your case above, where you want to group things up (like your RadioButtons) and maybe give them a title/header. QGroupBox also provides the possibilty to check/uncheck the whole box to enable/disable its content. You really dont need that for 2 simple buttons and 2 spacers (at least not in your use case).

                  @Detzi said in Line under radio Button and Button sizing in a Layout:

                  Although i don't understand how this is beneficial. I tried to read up why this is good practice here:

                  Make a new (Test)-project, skip the layout part and add random stuff. Then run your program and resize your window :)
                  You will see a huge difference in the resize / layout behavior of your widgets, esp. when you compare it with your current or any other project, that uses layouts correctly.
                  With layouts everything looks clean and resizes properly.


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

                  ~E. W. Dijkstra

                  1 Reply Last reply
                  3
                  • D Offline
                    D Offline
                    Detzi
                    wrote on 5 Apr 2021, 08:09 last edited by
                    #9

                    I think i understand. Thank you both very much for your time and effort.

                    M 1 Reply Last reply 5 Apr 2021, 08:36
                    0
                    • D Detzi
                      5 Apr 2021, 08:09

                      I think i understand. Thank you both very much for your time and effort.

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 5 Apr 2021, 08:36 last edited by
                      #10

                      @Detzi
                      Hi
                      Well the red layouts are meant to be used to sub divide another layout
                      and it not used as base layout as they float if not put in a layout.
                      So normally we apply a layout by right-click the widget and use the layout menu.

                      1 Reply Last reply
                      0

                      1/10

                      3 Apr 2021, 10:12

                      • Login

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