[英]qt: invalid property name 'x' (M16) for button
我在 QtCreator 3.3.1 中使用 Qt 5.4.1
我已經將 QtQuick.Controls 1.2 導入我的 QML 並添加了一系列按鈕:
Rectangle {
id: buttonBar
x: 480
y: 0
width: 320
height: 80
Button {
x: 0
y: 0
width: 80
height: 60
text: "Songs"
}
Button {
x: 80
y: 0
width: 80
height: 60
text: "Artists"
}
Button {
x: 160
y: 0
width: 80
height: 60
text: "Albums"
}
Button {
x: 240
y: 0
width: 80
height: 60
text: "Back"
}
}
當我運行程序時,它們都渲染得很好,但是每次 QtCreator 打開 qml 文件時,它都會跳轉到設計模式,我收到警告:
invalid property name 'x' (M16)
當我在編輯模式下查看文件時,我使用 x、y、寬度和高度的行都帶有下划線。
但文檔說這些是我的按鈕的有效屬性 - http://doc.qt.io/qt-5/qml-qtquick-controls-button-members.html
如何停止/解決此錯誤消息?
這是為使用 Qt Creator 的控件生成的類型信息中的錯誤。
要抑制此錯誤,請添加注釋:
Button {
// @disable-check M16
x: 80
y: 0
}
嘗試在 qml 中的所有其他導入之前添加導入 QtQuick.Window 2.2。
在解決任何其他導入和問題之前,我將這些導入移到了頂部:
import QtQml.Models 2.2
import QtQml 2.2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.