Change size of Quick Controls 2 items



  • 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?


  • Moderators

    @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 .



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.