Qml problem with signals, error 'Expected token `,'
-
Basically, any type of signal creates error when i run program. I use 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(); } }
}@
-
In Qt 5.3.1, you can bump the import to QtQuick 2.3.
Can you post exact error message you are seeing and the line it points to? Can you check whether your files are encoded using UTF-8, and what line endings are being used?
-
Sure, he is simplier program:
@import QtQuick 2.3
Rectangle {
width: 400;
height: 200;
color: "turquoise"Text {
text: "Press me"
anchors.centerIn: parent
font.family: "Algerian"
font.bold: true
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
styleColor: "#e80f54"
font.pixelSize: 48MouseArea { anchors.fill: parent onPressed: parent.color: "white" onReleased: parent.color: "black" }
}
}@
And the error message:
@Starting C:\Qt\5.3\mingw482_32\bin\qmlscene.exe...
file:///C:/Users/960757/Documents/projects/HelloWorld/HelloWorld.qml:20 Expected token `,'C:\Qt\5.3\mingw482_32\bin\qmlscene.exe exited with code -1@
Coding is UTF8. Where i check line endings?
-
Hm, indeed, I'm seeing the same error on my machine. There is no obvious reason for this that I am seeing. I'll investigate and write back shortly.
-
Ah, of course, such an obvious one, after all :-D
Slot code needs to be written in JavaScript syntax, not QML syntax. So you need to change your slots to this:
@
onPressed: parent.color = "white"
onReleased: parent.color = "black"
@ -
Parallel problem solving, nice ;-)