I am trying to apply some styles to a new qt 5.7 application I am working on and the following is not working at all. It gives the error: qrc:/SignInView.qml:67 Cannot assig
In Qt Quick Controls 2, there is no such property as TextField::style
. In general, there is no way to use the style objects from Qt Quick Controls 1 with Qt Quick Controls 2. The APIs between the two major versions of Qt Quick Controls are not compatible. See the following documentation pages for more details:
A new API-incompatible major version was introduced, because there is basically no way to make the heavily Loader-based architecture of Qt Quick Controls 1 perform reasonably well. Therefore all that dynamic loading of Component
s was ditched in Qt Quick Controls 2. The delegates that used to be dynamically instantiated from Component
s provided by a dynamically loaded style object are now part of the control instead, instantiated "in place". In essence:
TextField {
style: TextFieldStyle {
textColor: "white"
background: Rectangle { color: "black" }
}
}
vs.
TextField {
color: "white"
background: Rectangle { color: "black" }
}
You can read more about the history here. In particular, this post highlights the fundamental structural changes in Qt Quick Controls 2.