Qml QtQuick2 'Invalid property name "style"(M16)'
Qml QtQuick2 'Invalid property name "style"(M16)'
我正在 Qt5.7.0 QtCreator 4.1 中编写一个移动应用程序,我在 QtQuick qml 文件 'Invalid property name "style"(M16)' 中遇到错误并且表单不想显示某些内容。我做错了什么?
我必须先在项目中配置一些东西或者使用其他类型的文件吗?
我尝试在某些组件上使用此 属性,但它仅适用于 Text 对象,我不知道为什么。
这是我的代码:
//register_form.qml
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1
Item {
width: 270
height: 480
anchors.fill: parent
ColumnLayout {
id: loginLayout
anchors.rightMargin: 15
anchors.bottomMargin: 92
anchors.leftMargin: 23
anchors.topMargin: 91
anchors.fill: parent
TextField {
TextFieldStyle {
id: phoneStyle
placeholderTextColor: "grey"
}
id: phoneField
placeholderText: "+7 XXX XXX XX XX"
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
}
Button {
style: //error occurs here
ButtonStyle {
}
id: loginButton
text: "Next"
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
highlighted: true
}
}
}
对照 2 的 Button
doesn't have a style
property. The Button
that has it was the one 对照 1。
关于样式控件 2 个元素,take a look here。
我正在 Qt5.7.0 QtCreator 4.1 中编写一个移动应用程序,我在 QtQuick qml 文件 'Invalid property name "style"(M16)' 中遇到错误并且表单不想显示某些内容。我做错了什么?
我必须先在项目中配置一些东西或者使用其他类型的文件吗?
我尝试在某些组件上使用此 属性,但它仅适用于 Text 对象,我不知道为什么。
这是我的代码:
//register_form.qml
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1
Item {
width: 270
height: 480
anchors.fill: parent
ColumnLayout {
id: loginLayout
anchors.rightMargin: 15
anchors.bottomMargin: 92
anchors.leftMargin: 23
anchors.topMargin: 91
anchors.fill: parent
TextField {
TextFieldStyle {
id: phoneStyle
placeholderTextColor: "grey"
}
id: phoneField
placeholderText: "+7 XXX XXX XX XX"
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
}
Button {
style: //error occurs here
ButtonStyle {
}
id: loginButton
text: "Next"
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
highlighted: true
}
}
}
对照 2 的 Button
doesn't have a style
property. The Button
that has it was the one 对照 1。
关于样式控件 2 个元素,take a look here。