How i can detect when mouse is pressed and released inside widget area not outside it ?



  • Suppose i have a button and i want to detect mouse is pressed and released inside button only not in its parent widget or somewhere else.



  • Is anything wrong with signal clicked of [[Doc:QAbstractButton]]?

    Otherwise have a look at QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(), and QWidget::mouseMoveEvent().



  • Nothing wrong with that but i was trying to call a function just when a button is pressed before it is released but the problem is that if after pressing the button one is releasing dy"

    Nothing wrong with that but i was trying to call a function just when a button is pressed before it is released but the problem is that if after pressing the button one is releasing it only outside the button area i want to call another function. How i can i do that?
    I have checked mouse releaseEvent but mouse releasevent is called in both cases when mouse is released inside button or outside button area but i want to call it only in any of the one cases.



  • QApplication::widgetAt() together with the global position of the [[Doc:QMouseEvent]] could bring you a step further.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.