[Solved] Custom Radio Button style
-
Hi all,
I am relatively new to Qt and still learning my ways around it. I've been trying to customize the Radio button style in .qml as you can see in the code snippet below. I got everything to work as expected except the button label, which still shows the default style (text is too small). Can someone help me point out why Qt is not applying my custom text settings please?
Happy holidays,
@RadioButton
{
id: btnLabel
text: qsTr("Test label")
exclusiveGroup: radioBtnGroup
width: parent.width
checked: falsestyle: RadioButtonStyle { property Component label: Text { text: control.text font.pixelSize: 24 font.family: "DejaVu Sans" anchors.margins: 0 horizontalAlignment: Text.left } indicator: Rectangle { implicitWidth: 16 implicitHeight: 16 radius: 1 border.color: control.activeFocus ? "darkblue" : "gray" border.width: 1 Image { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter source: enabled ? "images/checked_active_icon.png" : "images/checked_inactive_icon.png" visible: control.checked } } } onClicked: { //TBD } }
@
-
try
@
label: Text
{
text: control.text
font.pixelSize: 24
font.family: "DejaVu Sans"
anchors.margins: 0
horizontalAlignment: Text.left
}
@instead of
@
property Component label: Text
{
text: control.text
font.pixelSize: 24
font.family: "DejaVu Sans"
anchors.margins: 0
horizontalAlignment: Text.left
}
@ -
It works! Thanks for the help.