[英]Qt Quick Controls Styles ReferenceError
我想在“ ComponentStyle.qml”(Qt5)之類的文件中隔離組件的樣式。
Item {
id:root
Component {
id: touchStyle
ButtonStyle {
....
}
}
Component {
id: switchStyle
SwitchStyle {
....
}
}
}
因此,在我的main.qml中,我想使用如下樣式:
...
Button {
style: touchStyle
text: "Press me"
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
}
但是,它不會工作! 我有一些錯誤:
文件:/// C:/Qt/5.2.0/msvc2012/qml/QtQuick/Controls/Switch.qml:133:TypeError:類型錯誤file:/// C:/Qt/5.2.0/msvc2012/qml/ QtQuick / Controls / Button.qml:92:TypeError:無法讀取null的屬性“ width”
main.qml:60:ReferenceError:未定義touchStyle *
有人可以幫助我嗎? 非常感謝 !
不幸的是,我認為我將不得不看到更多的ComponentStyle.qml,但我認為您缺少屬性。
您應該使用這兩個鏈接來全面了解如何格式化主題和樣式的代碼。
樣式 -在樣式文本和按鈕方面有很多很好的例子,非常適合您的情況。
QmlStyling-列出用於實現樣式的不同方法和技術。
希望對您有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.