Unsolved Not works style in the Switch
-
Hi!
Not works style in the Switch.
I get error: Cannot assign to non-existent property "style"import QtQuick 2.13 import QtQuick.Window 2.13 import QtQml 2.13 import QtQuick.Controls 2.13 import QtQuick.Controls.Styles 1.4 Switch { id: switch1 anchors.right: parent.right anchors.rightMargin: 10 anchors.top: parent.top anchors.topMargin: 10 style: SwitchStyle { groove: Rectangle { implicitWidth: 100 implicitHeight: 20 radius: 9 border.color: control.activeFocus ? "darkblue" : "gray" border.width: 1 } } }
.pro
QT += quick qml core multimedia gui network positioning location sql CONFIG += c++11
-
Your import statement for QtQuick.Controls is incorrect, see below;
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls.Styles 1.4 import QtQuick.Controls 1.4 `<----- change to 1.4` Window { visible: true width: 640 height: 480 title: qsTr("Switch Style") Switch { id: switch1 anchors.right: parent.right anchors.rightMargin: 10 anchors.top: parent.top anchors.topMargin: 10 style: SwitchStyle { groove: Rectangle { implicitWidth: 100 implicitHeight: 20 radius: 9 border.color: control.activeFocus ? "darkblue" : "gray" border.width: 1 } } } }
-
@Markkyboy said in Not works style in the Switch:
import QtQuick.Controls 1.4
This solution is not suitable for me, because I use Controls 2.13. Is there any other way to solve this?
-
@Mikeeeeee - change controls.styles to 1.4 as well, as per my code above. As far as I am aware neither Controls or Controls .Styles as 2.12/2.13 are not recognised.
-
-