Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Change size of radiobutton Qt Quick Controls 2
Forum Updated to NodeBB v4.3 + New Features

Change size of radiobutton Qt Quick Controls 2

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 6.4k 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.
  • K Offline
    K Offline
    koeniee
    wrote on last edited by
    #1

    Hello,

    I am wondering if it's possible to change the size of the RadioButton in QML in the Qt Quick Controls 2 library.
    Previously I used the Version 1 of the Qt Quick Controls library. All the components where smaller in version 1.

    I know it's possible to change the 'unselected' circle like this:

    RadioButton {
    	text: "Round X, -90 degr."
    	ButtonGroup.group: tabRotationGroup
    	Layout.preferredHeight: 15
    	indicator.height: 10
    	indicator.width: 10
    	onClicked:{ currentRotationIndex = 2 }
    }
    

    But the 'selected' circle is still big, it looks like this:

    RadioButtonBadExample

    Can someone help me? It looks really terrible...

    Kind regards,

    Koen

    E ekkescornerE 2 Replies Last reply
    0
    • K koeniee

      Hello,

      I am wondering if it's possible to change the size of the RadioButton in QML in the Qt Quick Controls 2 library.
      Previously I used the Version 1 of the Qt Quick Controls library. All the components where smaller in version 1.

      I know it's possible to change the 'unselected' circle like this:

      RadioButton {
      	text: "Round X, -90 degr."
      	ButtonGroup.group: tabRotationGroup
      	Layout.preferredHeight: 15
      	indicator.height: 10
      	indicator.width: 10
      	onClicked:{ currentRotationIndex = 2 }
      }
      

      But the 'selected' circle is still big, it looks like this:

      RadioButtonBadExample

      Can someone help me? It looks really terrible...

      Kind regards,

      Koen

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @koeniee Open the RadioButton.qml file in your Qt installation directory qml/QtQuick/Controls.2/. You can see that the indicator item is implemented with RadioIndicator type. Open RadioIndicator.qml. Now you can copy it to your own RadioButton and customize it.

      1 Reply Last reply
      1
      • K koeniee

        Hello,

        I am wondering if it's possible to change the size of the RadioButton in QML in the Qt Quick Controls 2 library.
        Previously I used the Version 1 of the Qt Quick Controls library. All the components where smaller in version 1.

        I know it's possible to change the 'unselected' circle like this:

        RadioButton {
        	text: "Round X, -90 degr."
        	ButtonGroup.group: tabRotationGroup
        	Layout.preferredHeight: 15
        	indicator.height: 10
        	indicator.width: 10
        	onClicked:{ currentRotationIndex = 2 }
        }
        

        But the 'selected' circle is still big, it looks like this:

        RadioButtonBadExample

        Can someone help me? It looks really terrible...

        Kind regards,

        Koen

        ekkescornerE Offline
        ekkescornerE Offline
        ekkescorner
        Qt Champions 2016
        wrote on last edited by
        #3

        @koeniee said in Change size of radiobutton Qt Quick Controls 2:

        Previously I used the Version 1 of the Qt Quick Controls library. All the components where smaller in version 1.

        are you developing for mobile platforms ?
        then it's recommended to have controls your users can easy touch. It's a common mis-design in mobile apps that controls are too small or don't have enough space around.
        a good explanation: https://www.smashingmagazine.com/2012/02/finger-friendly-design-ideal-mobile-touchscreen-target-sizes/

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.9 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        1 Reply Last reply
        1
        • K Offline
          K Offline
          koeniee
          wrote on last edited by
          #4

          No i am not developing for Mobile Platforms. I will customize the RadioButton Identicator.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koeniee
            wrote on last edited by
            #5

            I am trying to change the RadioButton style. But I only want to change the width and height,

            So according to this tutorial you can customize the Qt Quick Controls like this:

            https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-radiobutton

            But like I said, I only want to change two options (width and height of the child rectangle of the Indicator).

            I tried it like this:

            		RadioButton {
            			id: radio1
            			text: "Use whole geometry"
            			Layout.preferredHeight: 10
            			indicator: Rectangle{ //here starts my custom indicator.
            				Rectangle{
            					height: 10
            					width: 10
            				}
            			}
            			indicator.height: 10
            			indicator.width: 10
            			y: -20
            			ButtonGroup.group: segmentRadioGroup
            			onClicked:{
            				currentSegmentIndex = 1
            				onRadioSegmentType()
            			}
            		}
            
            E 1 Reply Last reply
            0
            • K koeniee

              I am trying to change the RadioButton style. But I only want to change the width and height,

              So according to this tutorial you can customize the Qt Quick Controls like this:

              https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-radiobutton

              But like I said, I only want to change two options (width and height of the child rectangle of the Indicator).

              I tried it like this:

              		RadioButton {
              			id: radio1
              			text: "Use whole geometry"
              			Layout.preferredHeight: 10
              			indicator: Rectangle{ //here starts my custom indicator.
              				Rectangle{
              					height: 10
              					width: 10
              				}
              			}
              			indicator.height: 10
              			indicator.width: 10
              			y: -20
              			ButtonGroup.group: segmentRadioGroup
              			onClicked:{
              				currentSegmentIndex = 1
              				onRadioSegmentType()
              			}
              		}
              
              E Offline
              E Offline
              Eeli K
              wrote on last edited by
              #6

              @koeniee I suggest you create your own RadioIndicator. For example SmallerRadioIndicator.qml where you have copied the RadioIndicator.qml of your Qt installation. Change the needed implicitHeight/implicitWidth values there. Use that component in your radio buttons. Downsides are that you will have one more component and that when the standard implementation will be changed you have to update your component if you want it to be identical to the standard implementation.

              You can also handle the values runtime in Component.onCompleted. However, there's no way to reach the inner rectangle in any standard way. Maybe you can find the first child object of the indicator and change the values that way. It's kind of hackish though and relies on implementation details of the original RadioIndicator which may change in future versions, and may be different in different styles. It's just not guaranteed that a radio button indicator has outer and inner rectangles.

              Personally I feel that one of the most frustrating features of QML is exactly this - you can't make small changes to existing styles without copying whole components or relying on hacks.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                Kenz Dale
                wrote on last edited by
                #7

                Old topic, but the situation is still unresolved. I have created a bugreport with a suggestion for how to fix this problem: https://bugreports.qt.io/browse/QTBUG-95385

                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 Extensions
                • Unsolved