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. How i can detect when mouse is pressed and released inside widget area not outside it ?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 7.1k 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
    pratik041
    wrote on last edited by
    #1

    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.

    Pratik Agrawal

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

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

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

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        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.

        Pratik Agrawal

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

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

          http://www.catb.org/~esr/faqs/smart-questions.html

          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