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 Quick Controls 2 items
Forum Update on Monday, May 27th 2025

Change size of Quick Controls 2 items

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.6k 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.
  • S Offline
    S Offline
    Schluchti
    wrote on last edited by Schluchti
    #1

    Hi,

    is there an easy way to change the size of Quick Controls 2 components, without subclassing the items?

    For example: I want to change the size of a Switch component. I know that I can customize by doing this (http://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-switch), but I am happy with the default appearance of the Switch. The only thing that I would like to change is, to make the size of the indicator a little bit bigger (on Android it looks a little bit small).

    I tried to do the following:

    Switch {
        width: 300
        height: 300
    }
    

    The above unfortunately does not change the size of the indicator.

    Next, I tried the following:

    Switch {
        indictator.width: 300
        indicator.height: 300
    }
    

    Now, the indicator's width changed, but height doesn't change.

    Is there an easy way to accomplish that without customizing the Switch?

    Want to read more about Qt?

    https://gympulsr.com/blog/qt/

    Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Schluchti Check the following document and read from "The second way to ..."
      So far I understand from it is that you can override the defautl style by copy pasting the original code in your project, do the changes and rename the file. Then later use this new component in your code. The example provided show a simple Button control. You can try following the same way for Switch .

      157

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Schluchti
        wrote on last edited by
        #3

        Many thanks for the info!

        I did something similar a few days ago: But instead of copying the whole component (in my case Switch.qml) I just copied the indicator implementation (SwitchDelegate.qml) and adapted that to my needs (i.e make it bigger). I thought that I can maybe solve that without copy and pasting the delegate, but it looks like that's the way to do it :)

        Thanks!

        Have a nice day,
        Bernhard

        Want to read more about Qt?

        https://gympulsr.com/blog/qt/

        Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

        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