Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml problem with signals, error 'Expected token `,'
Forum Updated to NodeBB v4.3 + New Features

Qml problem with signals, error 'Expected token `,'

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 6.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 1 Offline
    1 Offline
    169Martin
    wrote on 12 Aug 2014, 09:46 last edited by
    #1

    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();
    
        }
    }
    

    }@

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 12 Aug 2014, 10:09 last edited by
      #2

      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?

      (Z(:^

      1 Reply Last reply
      0
      • 1 Offline
        1 Offline
        169Martin
        wrote on 12 Aug 2014, 10:16 last edited by
        #3

        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: 48

           MouseArea {
               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?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 12 Aug 2014, 10:31 last edited by
          #4

          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.

          (Z(:^

          1 Reply Last reply
          0
          • 1 Offline
            1 Offline
            169Martin
            wrote on 12 Aug 2014, 10:31 last edited by
            #5

            @MouseArea {
            anchors.fill: parent
            onPressed: parent.color = "white"
            onReleased: parent.color = "black"
            }
            @

            This is solution ;)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 12 Aug 2014, 10:33 last edited by
              #6

              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"
              @

              (Z(:^

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sierdzio
                Moderators
                wrote on 12 Aug 2014, 10:33 last edited by
                #7

                Parallel problem solving, nice ;-)

                (Z(:^

                1 Reply Last reply
                0

                1/7

                12 Aug 2014, 09:46

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved