Results 1 to 10 of 10

Thread: Mouse Right or Left click ???

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Mouse Right or Left click ???

    first, how deletes the event in your code? and is window() returning a valid pointer and is the point value correct for window()?

  2. #2
    Join Date
    Aug 2011
    Location
    India
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Mouse Right or Left click ???

    Thanks Lykurg

    Now I have changed my code a bit to this:

    Qt Code:
    1. void Widget::on_pushButton_6_clicked()
    2. {
    3. QTimer::singleShot(4000, this, SLOT(clickAction()));
    4. }
    5.  
    6. void Widget::clickAction()
    7. {
    8. QObject *desk = QApplication::activeWindow();
    9. QPoint point(cur.pos().x(), cur.pos().y());
    10. ui->plainTextEdit->appendPlainText("X:" + QString::number(cur.pos().x()) + " Y:" + QString::number(cur.pos().y()));
    11. QApplication::postEvent(desk, new QMouseEvent(QMouseEvent::MouseButtonPress,point,Qt::RightButton, Qt::RightButton,Qt::NoModifier));
    12. QApplication::postEvent(desk, new QMouseEvent(QMouseEvent::MouseButtonRelease,point,Qt::RightButton, Qt::RightButton,Qt::NoModifier));
    13. }
    To copy to clipboard, switch view to plain text mode 

    as you can see that the Window() is the current active window.
    When I click the button which creates the timer for 5 sec, I quickly point and click the curson on the Desktop to make it the current window and after the timer timeouts I expect an Right Click event...but I get the correct co-ordinates (X, Y) value but still not Right Click happens...pls help

Similar Threads

  1. Replies: 8
    Last Post: 2nd September 2010, 15:49
  2. Replies: 4
    Last Post: 29th August 2010, 18:16
  3. Qtablewidget left mouse click event in python
    By gerocampo in forum Newbie
    Replies: 0
    Last Post: 23rd July 2010, 17:05
  4. Replies: 4
    Last Post: 30th May 2010, 12:55
  5. Emulating Enter key with left mouse click
    By wconstan in forum Newbie
    Replies: 6
    Last Post: 30th December 2009, 16:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.