QT. Styles don't work in.qml file
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls 2.2
Button {
id: trunclateBtn
text: qsTr("Перевести")
style: Rectangle{
}
}
Style is highlighted in red and throws the error " Incorrect name of the style property (M16)", although it seems to have connected everything, everything is also done in the documentation.
0
1 answers
UPD: The original answer was deleted due to its uselessness.
It's all about Qt Quick Controls. You are using version 2, and the style
component property has been removed (unlike version 1). Here here describes the differences and provides an example specifically for style
.
To solve your problem, you need to:
- or simply change
QtQuick.Controls 2.2
toQtQuick.Controls 1.2
; - or leave version 2.2, but use the
contentItem
property.
Option for QtQuick.Controls 2.2
:
Button {
contentItem: Rectangle {
width: 100
height: 20
color: "red"
// ...
}
}
1
Author: Neilana, 2018-02-07 16:27:02