Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Class for replacing the mouse click
Forum Updated to NodeBB v4.3 + New Features

Class for replacing the mouse click

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 3.6k 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.
  • R Offline
    R Offline
    romeo.rbw
    wrote on 7 Jun 2012, 03:19 last edited by
    #1

    Dear Qt ers,

    Hi...I need your suggestion, is there any class or function to replace a mouse click if I already know the coordinate of the cursor?

    Thank you in advance.

    -romeo

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Blizzard
      wrote on 8 Jun 2012, 05:30 last edited by
      #2

      In your function that grabs the coordinates, you can write something like
      @if (event->button() == Qt::LeftButton) doSomething();@

      Software Engineer | Aerospace & Defence

      1 Reply Last reply
      0
      • R Offline
        R Offline
        romeo.rbw
        wrote on 8 Jun 2012, 07:20 last edited by
        #3

        Thanks for replying my thread Sir.
        May be my question was not so clear because my language limitation. I'm sorry for that.

        I have a pair of coordinate (x,y), after that I used 'setPos' function in QCursor class to move my mouse cursor. It has already done, the cursor moved to the desired (x,y) successfully without touched a "physical mouse".
        After pointing this cursor to (x,y) position, I want to give a click action like a mouse do. Would you give some suggestion.

        Thanks
        -romeo

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Blizzard
          wrote on 8 Jun 2012, 17:58 last edited by
          #4

          Just connect the mouse move event (which you have already achieved) to a slot that the user's mouse click would normally trigger. Instead of using clicked() as the signal, you can create a custom signal for the mouse move event. An example of creating custom signals can be found "here":http://doc.trolltech.com/4.5/signalsandslots.html#a-small-example.

          Software Engineer | Aerospace & Defence

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DerManu
            wrote on 8 Jun 2012, 18:38 last edited by
            #5

            I think he wants to make the mouse click programmatically, not act on a mouse click event.

            I'm not aware of a platform independent way to do this.
            If you're restrained to Microsoft® Windows®: I remember using the WinAPI function mouse_event with parameter MOUSEEVENTF_LEFTDOWN/UP, back in my dark, miserable Microsoft® Windows® days.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Blizzard
              wrote on 8 Jun 2012, 18:43 last edited by
              #6

              I didn't say a mouse click event, I said mouse move. Why do users click with their mouse? To trigger something. So the simple solution is to to have that "thing" trigger on the event where the mouse's coordinates reach the coordinates he specified.

              Software Engineer | Aerospace & Defence

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DerManu
                wrote on 8 Jun 2012, 19:00 last edited by
                #7

                So when the coordinates are over a different application, how would you reach into that application to trigger that event a mouse click would trigger? I'm afraid it's not quite as easy as you think, thus just making the mouse perform a click and let the operating system and the other application handle the rest will be the easier way.

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  Blizzard
                  wrote on 8 Jun 2012, 19:11 last edited by
                  #8

                  When did he say he is running multiple applications? I assume you mean "coordinates over a different WIDGET" - not application?

                  According to the question, there is a static pair of coordinates (x, y), and he has a scenario where the user's mouse is forced to move to that (x, y). Now that the mouse is at the (x, y) position, he wants to emulate a mouse click. A mouse click sends a clicked() signal in Qt, so all he would need to do is replace that with a custom signal that gets sent when the mouse reaches that (x, y) location.

                  Software Engineer | Aerospace & Defence

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    romeo.rbw
                    wrote on 11 Jun 2012, 01:07 last edited by
                    #9

                    Thank you for every reply and some discussion about that. Actually I need an emulate of a mouse click because after that I can do emulate drag action too. So after "click" action I can move an object in the coordinate (x,y) to another location (a new x,y location) like a mouse drag action do. I hope i can move a rectangle without using a "physical mouse", but only using my coordinates.

                    -romeo

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      Blizzard
                      wrote on 11 Jun 2012, 01:28 last edited by
                      #10

                      So you are looking to do animation then - take a look at "Qt's animation framework documentation":http://doc.qt.nokia.com/4.7-snapshot/animation-overview.html.

                      Software Engineer | Aerospace & Defence

                      1 Reply Last reply
                      0

                      1/10

                      7 Jun 2012, 03:19

                      • Login

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