Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] qml and qt: pressing buttons
Forum Update on Monday, May 27th 2025

[SOLVED] qml and qt: pressing buttons

Scheduled Pinned Locked Moved Mobile and Embedded
11 Posts 4 Posters 4.0k Views
  • 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.
  • S Offline
    S Offline
    spode
    wrote on 21 Jul 2011, 08:16 last edited by
    #1

    how to receive the "button pressed"'s signal? i would to say this: !http://farm7.static.flickr.com/6004/5960480374_db013832fc_m.jpg()!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thisisbhaskar
      wrote on 21 Jul 2011, 08:27 last edited by
      #2

      your question is not clear and link to the image does not work...

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chuck Gao
        wrote on 21 Jul 2011, 08:27 last edited by
        #3

        Use signals & slots. If you using Qt C++, it's easy to connect your signals & slots. If you using QML, i assumed you use your custom button element, so you can:

        1. In your button's mouseArea, do something when
          @onPressed: {}@
        2. Use connect to make your signal and function's connection.

        I think you'd better read how to use signals & slots with QML first :D

        Chuck

        1 Reply Last reply
        0
        • S Offline
          S Offline
          spode
          wrote on 21 Jul 2011, 11:25 last edited by
          #4

          try !http://www.flickr.com/photos/64362284@N04/5960480374/in/photostream()!

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thisisbhaskar
            wrote on 21 Jul 2011, 12:03 last edited by
            #5

            I guess these buttons are Qt::Key_Send, Qt::Key_Menu, and Qt::Key_End

            Inside your qml item
            @Keys.onPressed: {
            if (event.key == Qt.Key_Send) {
            console.log("call button pressed");
            event.accepted = true;
            }
            }
            @

            1 Reply Last reply
            0
            • S Offline
              S Offline
              spode
              wrote on 21 Jul 2011, 13:13 last edited by
              #6

              oh it is possible! can someone confirm it, please? an example in qml please?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on 21 Jul 2011, 13:15 last edited by
                #7

                Vijay's "Keys.onPressed" snippet is an example in QML. What more do you need?

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  spode
                  wrote on 21 Jul 2011, 13:26 last edited by
                  #8

                  right, however can someone confirm?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mlong
                    wrote on 21 Jul 2011, 13:28 last edited by
                    #9

                    It looks reasonable to me... should be easy enough to test.

                    console.log() is your friend.

                    Software Engineer
                    My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Chuck Gao
                      wrote on 21 Jul 2011, 13:57 last edited by
                      #10

                      [quote author="Vijay Bhaska Reddy" date="1311249782"]I guess these buttons are Qt::Key_Send, Qt::Key_Menu, and Qt::Key_End

                      Inside your qml item
                      Keys.onPressed: {
                      if (event.key == Qt.Key_Send) {
                      console.log("call button pressed");
                      event.accepted = true;
                      }
                      }
                      [/quote]

                      Also, if you want to recieve keyboard events, make sure this:
                      @
                      // Inside your element definition
                      focus: true
                      @

                      Chuck

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        spode
                        wrote on 22 Jul 2011, 10:20 last edited by
                        #11

                        thank everybody!

                        1 Reply Last reply
                        0

                        5/11

                        21 Jul 2011, 12:03

                        • Login

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