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. Left Mouse press click not generated

Left Mouse press click not generated

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.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.
  • P Offline
    P Offline
    psbhardwaj09gmail.com
    wrote on last edited by
    #1

    HI,
    I Have an application in which i want to capture the coordinates of mouse when i clicked mouse's left button. But its not working for left click while its working fine for right button. My mousePressEvent implementation is as follow:
    @
    void MyClassName::mousePressEvent(QMouseEvent *event)
    {
    qDebug()<<"x->"<<event->pos().x()<<", y->"<<event->pos().y();

    }@

    with this code if i click right buttn position of x & y get displayed but not in case of left click because mousePressEvent(QMouseEvent *event) not getting hit.

    So please give me suggestion for that

    Rgds
    Pardeep Sharma

    Pardeep Sharma

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kernald
      wrote on last edited by
      #2

      Does your object contains any other sub widgets? If so, maybe one of them is already handling left clicks, so consumes the event, but ignore right clicks.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vittalonline
        wrote on last edited by
        #3

        Hi Pardeep Sharma,

        Use this code in ::mousePressEvent(QMouseEvent *event)

        it works only if left mouse button is down

        if (event->button() == Qt::LeftButton) {
            // **left click 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