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. MOuse Click event in Window/desktop by susing QT
QtWS25 Last Chance

MOuse Click event in Window/desktop by susing QT

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 5.7k 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.
  • K Offline
    K Offline
    kuppan-j
    wrote on last edited by
    #1

    Mouse button clicki am trying to create an automatic mouse click event at a particular co ordinate.

    This source code moves the mouse pointer to the co ordinate region but it is not clicking.

    please help me to solve this problem or suggest any new idea to automate mouse click event.

    I am seek of this.....???

    Note: i am using QT 3.0.3

    void mMouseClickFunction()
    {

    QWidget *d = QApplication::desktop()->screen();
    int w=d->width(); // returns desktop width
    int h=d->height();
    printf("w=%d\nh=%d\n",w,h);
    int x,y;
    printf("Enter the points...\n");
    scanf("%d%d",&x,&y);
    QApplication::desktop()->cursor().setPos(x,y);
    QPoint pt(x,y);
    std::cout << pt.x() << " " << pt.y() << std::endl;
    QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, pt,Qt::LeftButton, 0);
    QApplication::sendEvent(d, e);
    std::cout << "in contentsMousePressEvent" \
    << e->x() << " " << e->y() << std::endl;
    QMouseEvent *p = new QMouseEvent(QEvent::MouseButtonRelease, pt,Qt::LeftButton, 0);
    QApplication::sendEvent(d, p);
    std::cout << "in contentsMouseReleaseEvent" \
    << p->x() << " " << p->y() << std::endl;

    }

    1 Reply Last reply
    0
    • M Offline
      M Offline
      messi
      wrote on last edited by
      #2

      What does QMouseEvent::globalPos() gives back?

      Check the doc: http://doc.qt.digia.com/3.3/qmouseevent.html#globalPos

      Maybe this will help you.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kuppan-j
        wrote on last edited by
        #3

        Please help me to solve the problem or suggestions may appreciated

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuppan-j
          wrote on last edited by
          #4

          juergen_M@ QMouseEvent::globalPos() gives correct mouse event position whatever i am giving through scanf(ā€%d%dā€,&x,&y); in the above code.

          But it is not simulating mouse click event on the position.......????

          1 Reply Last reply
          0
          • M Offline
            M Offline
            messi
            wrote on last edited by
            #5

            Your goal is to write a click simulation software.
            A normal click under linux/X11 would be Mouse->XInput->QEvent
            What you would like to do is QEvent->XInput

            Here is a possible google solution:
            http://stackoverflow.com/questions/10081588/qt-monitor-global-cursor-click-event-with-x11

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kuppan-j
              wrote on last edited by
              #6

              juergen_M@
              i already implemented what u suggested for x11 its working fine.....but i am using is cross compiler xscale_le-g++ ....i need the same x11 implemetation for cross compiler??? is it possible???

              1 Reply Last reply
              0
              • M Offline
                M Offline
                messi
                wrote on last edited by
                #7

                In general yes. So you are using X11 on your xscale target. If this is the case your PC code should work on the target as well

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kuppan-j
                  wrote on last edited by
                  #8

                  So Mouse click event is not posible in QT?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    messi
                    wrote on last edited by
                    #9

                    No it is possible. You have to map QMouseEvent to XInputEvent.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kuppan-j
                      wrote on last edited by
                      #10

                      canu pls able to add a related line to resolve the problem with my above mentioned code????

                      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