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. [Solved] What is a valid signal for a Switch component?
Forum Updated to NodeBB v4.3 + New Features

[Solved] What is a valid signal for a Switch component?

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 3 Posters 6.4k 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.
  • C Offline
    C Offline
    CaCO3
    wrote on last edited by
    #1

    I am trying to figure out how to use a signal of a QML Switch component (http://doc.qt.nokia.com/qt-components-symbian-1.0/qml-switch.html ).

    According to above link (Qt components 1.0) it should work with the signal clicked, how ever I get this error:
    Cannot assign to non-existent property "clicked"

    I had a look on /usr/lib/qt4/imports/com/nokia/meego/Switch.qml.
    It defines the following signals:

    •   onClicked
      
    •  onPositionChanged
      
    •  onReleased
      
    •  onCanceled
      

    But none of them works either :(

    Below is a example code.
    The version with the CheckBox and Button work fine.

    @import QtQuick 1.0
    import com.nokia.meego 1.0

    Column{

    Switch{
    

    // clicked: { console.log("Switch toggled") }
    // onClicked: { console.log("Switch toggled") }
    // onPositionChanged: { console.log("Switch toggled") }
    // onReleased: { console.log("Switch toggled") }
    // onCanceled: { console.log("Switch toggled") }
    }

    CheckBox{
    

    onClicked: { console.log("checkbox toggled") }
    }

    Button{
    

    text: "Button"
    onClicked: { console.log("Button clicked") }
    }

    }@

    1 Reply Last reply
    0
    • S Offline
      S Offline
      srikanth_trulyit
      wrote on last edited by
      #2

      clicked is a signal, so you should have a signal handler namely onClicked, You cannot use it as a property.
      @
      Switch {
      id: mySwitch
      onClicked: console.debug("switch is clicked");
      }
      @

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CaCO3
        wrote on last edited by
        #3

        Did you try it yourself?
        Because for me it doesn't work either:
        Cannot assign to non-existent property "onClicked"

        1 Reply Last reply
        0
        • S Offline
          S Offline
          srikanth_trulyit
          wrote on last edited by
          #4

          Yes, I tried on Symbian components. Since it is a non-platform specific property it should work on Meego.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CaCO3
            wrote on last edited by
            #5

            Hmmm, that really surprises me :(

            I tested it on my Linux PC as well as on My N950 (Harmattan).
            I both OS I get this error:
            Cannot assign to non-existent property "onClicked"

            In google I found this page which should be reference to the switch component for Harmattan:
            http://library.developer.nokia.com/topic/MeeGo_1.2_Harmattan_API/html/qt-components/qt-components-meego-switch.html
            How ever this page seems not to exist anymore. Here is a cached version from google:
            http://webcache.googleusercontent.com/search?q=cache:iF5s0BE30BUJ:library.developer.nokia.com/topic/MeeGo_1.2_Harmattan_API/html/qt-components/qt-components-meego-switch.html+qml+switch&cd=3&hl=de&ct=clnk&client=ubuntu

            To my surprise, there is no signal mentioned. :(
            As a comparison, the checkbox has a signal clicked:
            http://webcache.googleusercontent.com/search?q=cache:tP2Tj6DNmCgJ:library.developer.nokia.com/topic/MeeGo_1.2_Harmattan_API/html/qt-components/qt-components-meego-checkbox.html+qml+checkbox&cd=6&hl=de&ct=clnk&client=ubuntu

            So I am wondering, why does it work on Symbian but not under Linux/Harmattan?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              cpscotti
              wrote on last edited by
              #6

              Hey CaCO3,

              I think I have the solution:
              @
              Switch {
              id: switch2
              checked: true
              onCheckedChanged: {
              console.log("test")
              }
              }
              @
              Tried it on my n950 and it worked flawlessly. How I figured it out? QtCreator's Auto-complete.. :D

              cpscotti.com/blog/ - Used when I need to kill some time at work :D

              1 Reply Last reply
              0
              • C Offline
                C Offline
                CaCO3
                wrote on last edited by
                #7

                Thank you very much :)

                I completely stopped using QtCreator.

                When I started with QML, everybody told me not to use QtCreator as it doesn't work well.
                And indeed, the graphical part never worked for me.
                Because of that I changed to the normal text editor.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  cpscotti
                  wrote on last edited by
                  #8

                  CaCO3,
                  Lol! Well, the auto-complet/code-assist thing's not perfect but helps a lot. The same for the integrated documentation, not perfect but helps.
                  The graphical thing's really badly useless/broken and using it's completely out of the question.
                  Except when you just want to see "what's possible".. like a quick documentation on styles, anchors.. properties.. etc.

                  All in all, I'm enjoying Qt Creator a lot.. they are working hard on it and it's getting better and better everyday. :D

                  cpscotti.com/blog/ - Used when I need to kill some time at work :D

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    CaCO3
                    wrote on last edited by
                    #9

                    You are right, its a great tool and I am looking forward to see it working.

                    How ever as a Linux freak I often write smaller projects in a plain text editor and compile in the terminal. Linux has such good plain text editors and its so much faster.
                    Also, when you type the code by hand you also understand what you do :)

                    But you are right, in the beginning i also used QtCreator to generate example code. Now I just forgot about that nice tool :)

                    1 Reply Last reply
                    0

                    • Login

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