I am trying to make a very simple program to learn how to define custom QML types for reuse. I'm not sure why I'm getting the following error:
Cannot assign to non-existent property "color"
I have searched for an answer and have not found anything that solves it.
Below is the code. Qt underlines color
and radius
in red, meaning that it is being flagged as an "invalid property name."
//Button.qml
import QtQuick 2.3
Rectangle {
width: 100; height: 100
color: "red"
MouseArea {
anchors.fill: parent
onClicked: console.log("button clicked!")
}
}
//main.qml
import QtQuick 2.3
import QtQuick.Controls 1.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
Column {
Button {width: 50; height: 50}
Button { x: 50; width: 100; height: 50; color: "blue" }
Button { width: 50; height: 50; radius: 8}
}
}