I want to isolate the style of my components in a file like "ComponentStyle.qml" (Qt5)
ComponentSyle.qml
Item {
id:root
Component {
id: touchStyle
ButtonStyle {
....
}
}
Component {
id: switchStyle
SwitchStyle {
....
}
}
}
So, in my main.qml, I want to use the style like :
main.qml
...
Button {
style: touchStyle
text: "Press me"
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
}
But, it wont work ! I have some errors :
file:///C:/Qt/5.2.0/msvc2012/qml/QtQuick/Controls/Switch.qml:133: TypeError: Type error file:///C:/Qt/5.2.0/msvc2012/qml/QtQuick/Controls/Button.qml:92: TypeError: Cannot read property 'width' of null
main.qml:60: ReferenceError: touchStyle is not defined*
Is someone can help me ? Thanks a lot !