Reputation: 151
Qt Creator 3.1.2 Based on Qt 5.3.1 (MSVC 2010, 32 bit).Project has import QmlProject 2.0 Here is my program where i have this error. This program is from tutorial and it worked for him..so im not sure whats the problem there.
import QtQuick 2.0
Rectangle {
id: rootTangle
width: 360
height: 360
color: "red"
hoverEnabled: true;
Rectangle {
id: blueRec
color: "blue"
//opacity: .50
width: rootTangle.width/2
height: rootTangle.width/6
anchors.centerIn: rootTangle
border.color: "black"
border.width: 7
rotation: 180
radius: 20
gradient: Gradient {
GradientStop { position: 0.0; color: "#b0c5de" }
GradientStop { position: 1.0; color: "blue" }
}
}
Text {
id: nazdarTxt
anchors.centerIn: blueRec
text: "Nazdar"
clip: false
visible: true
font.family: "Times New Roman"
font.bold: true
//font.pixelSize: Math.round(blueRec.height/3)
width: blueRec.width
//wrapMode: Text.WordWrap
}
MouseArea {
id: blueRecMouseArea
hoverEnabled: true;
onEntered: {
blueRec.color: "brown"
}
anchors.rightMargin: 0
anchors.bottomMargin: 0
anchors.leftMargin: 1
anchors.topMargin: 0
anchors.fill: blueRec
onClicked: {
Qt.quit();
}
}
}
The error is on the line 46 : onEntered: {
blueRec.color: "brown"
}
Upvotes: 2
Views: 14345
Reputation: 3982
The problem is the colon after color:
onEntered: {
blueRec.color: "brown"
}
You should change to equal sign:
onEntered: {
blueRec.color = "brown"
}
Also there's no hoverEnabled in Rectangle, so you will need to remove or comment it:
Rectangle {
id: rootTangle
width: 360
height: 360
color: "red"
//hoverEnabled: true;
And since you already defined a Gradient for blueRec, changing its color has no effect, you should instead change the gradient colors:
onEntered: {
blueRec.gradient.stops[0].color = "brown"
blueRec.gradient.stops[1].color = "white"
}
Upvotes: 5