Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. RoundButton not taking correct height setting
Qt 6.12 LTS is out! See what's new in the release blog

RoundButton not taking correct height setting

Scheduled Pinned Locked Moved Solved Mobile and Embedded
16 Posts 2 Posters 2.6k Views 1 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.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #7

    @mzimmers said in RoundButton not taking correct height setting:

    height: r1.height

    change
    height: r1.height
    to
    implicitHeight: r1.height
    will do it.

    Setting the implicit size is useful for defining components that have a preferred size based on their content.

    mzimmersM 1 Reply Last reply
    0
    • JoeCFDJ JoeCFD

      @mzimmers said in RoundButton not taking correct height setting:

      height: r1.height

      change
      height: r1.height
      to
      implicitHeight: r1.height
      will do it.

      Setting the implicit size is useful for defining components that have a preferred size based on their content.

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #8

      @JoeCFD said in RoundButton not taking correct height setting:

      change
      height: r1.height
      to
      implicitHeight: r1.height
      will do it.

      I assume that change was for the RowLayout, as that's the only place with that exact line of code. It didn't change anything. If I make that change to b1 as well, b1 then looks like b2, which isn't what I want.

      Setting the implicit size is useful for defining components that have a preferred size based on their content.

      But in this case, I want to dictate the size (height) of the button. I want it to be exactly half the height of the rectangle in which it's being placed. That's why I'm not sure implicit sizes are appropriate here.

      JoeCFDJ 1 Reply Last reply
      0
      • mzimmersM mzimmers

        @JoeCFD said in RoundButton not taking correct height setting:

        change
        height: r1.height
        to
        implicitHeight: r1.height
        will do it.

        I assume that change was for the RowLayout, as that's the only place with that exact line of code. It didn't change anything. If I make that change to b1 as well, b1 then looks like b2, which isn't what I want.

        Setting the implicit size is useful for defining components that have a preferred size based on their content.

        But in this case, I want to dictate the size (height) of the button. I want it to be exactly half the height of the rectangle in which it's being placed. That's why I'm not sure implicit sizes are appropriate here.

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #9

        @mzimmers change all of them. I tested the change. They are all 30

        import QtQuick 2.15
        import QtQuick.Controls 2.15
        import QtQuick.Layouts 1.15
        
        ApplicationWindow {
            id: mainWindow
            width: 1024
            height: 768
            visible: true
        
            ColumnLayout {
                Rectangle {
                    id: r1
                    height: 60
                    width: mainWindow.width
                    color: 'red'
        
                    RowLayout {
                        id: rowLayout
        
                        Button {
                            id: b1
                            implicitHeight : r1.height / 2
                            text: b1.height
                        }
                    }
                }
        
                Rectangle {
                    id: r2
                    height: 60
                    width: mainWindow.width
                    color: 'blue'
                    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    Button {
                        id: b2
                        implicitHeight: r2.height / 2
                        text: b2.height
                    }
                }
        
                Button {
                    id: b3
                    implicitHeight: r2.height / 2 // just borrowing the height from r2.
                    text: b3.height
                }
            }
        }
        
        mzimmersM 1 Reply Last reply
        0
        • JoeCFDJ JoeCFD

          @mzimmers change all of them. I tested the change. They are all 30

          import QtQuick 2.15
          import QtQuick.Controls 2.15
          import QtQuick.Layouts 1.15
          
          ApplicationWindow {
              id: mainWindow
              width: 1024
              height: 768
              visible: true
          
              ColumnLayout {
                  Rectangle {
                      id: r1
                      height: 60
                      width: mainWindow.width
                      color: 'red'
          
                      RowLayout {
                          id: rowLayout
          
                          Button {
                              id: b1
                              implicitHeight : r1.height / 2
                              text: b1.height
                          }
                      }
                  }
          
                  Rectangle {
                      id: r2
                      height: 60
                      width: mainWindow.width
                      color: 'blue'
                      Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                      Button {
                          id: b2
                          implicitHeight: r2.height / 2
                          text: b2.height
                      }
                  }
          
                  Button {
                      id: b3
                      implicitHeight: r2.height / 2 // just borrowing the height from r2.
                      text: b3.height
                  }
              }
          }
          
          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #10

          @JoeCFD they say 30, but they are not half the height of the rectangles I'm placing them in:
          buttons.PNG

          That is what I'm trying to fix (plus another problem I'll bring up later).

          Thanks...

          JoeCFDJ 1 Reply Last reply
          0
          • mzimmersM mzimmers

            @JoeCFD they say 30, but they are not half the height of the rectangles I'm placing them in:
            buttons.PNG

            That is what I'm trying to fix (plus another problem I'll bring up later).

            Thanks...

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #11

            @mzimmers what do you mean?
            r1 height is 60
            b1 height is 60 / 2 = 30
            my display of the button has the half height.

            mzimmersM 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @mzimmers what do you mean?
              r1 height is 60
              b1 height is 60 / 2 = 30
              my display of the button has the half height.

              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by mzimmers
              #12

              @JoeCFD look at my picture. The buttons don't look anywhere near half the height of the rectangles. From eyeballing it, it looks more like 1/3 the height.

              EDIT:

              Using a background seems to fix it (sort of). Let me play with this and I'll report back.

              JoeCFDJ 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @JoeCFD look at my picture. The buttons don't look anywhere near half the height of the rectangles. From eyeballing it, it looks more like 1/3 the height.

                EDIT:

                Using a background seems to fix it (sort of). Let me play with this and I'll report back.

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #13

                @mzimmers display.png

                mzimmersM 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @mzimmers display.png

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #14

                  @JoeCFD interesting. I wonder why yours doesn't look like mine. What's your platform and style?

                  JoeCFDJ 1 Reply Last reply
                  0
                  • mzimmersM mzimmers

                    @JoeCFD interesting. I wonder why yours doesn't look like mine. What's your platform and style?

                    JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by JoeCFD
                    #15

                    @mzimmers Qt 5.15.2 on Ubuntu 18. Maybe try also
                    implicitHeight: 60

                    mzimmersM 1 Reply Last reply
                    0
                    • JoeCFDJ JoeCFD

                      @mzimmers Qt 5.15.2 on Ubuntu 18. Maybe try also
                      implicitHeight: 60

                      mzimmersM Offline
                      mzimmersM Offline
                      mzimmers
                      wrote on last edited by mzimmers
                      #16

                      @JoeCFD interesting...the problem appears to be specific to the Material style. Applying a background makes it better (though it still doesn't look quite right).

                      EDIT: I also discovered that the Material style isn't displaying the icon correctly. I'm going to close this topic and open a new one.

                      1 Reply Last reply
                      0

                      • Login

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