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. Get Event

Get Event

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 4.0k 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.
  • S Offline
    S Offline
    Sorin
    wrote on last edited by
    #1

    I have a QToolButton with a menu on it( InstantPopup ). I press the button, menu appears and after that I press outside the button, how should I catch this event related to my button?
    Thanks!

    There are only 10 types of people in the world: Those who understand binary, and those who don't

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stukdev
      wrote on last edited by
      #2

      I don't understand what event you want, but if you want catch an event of the QToolButton you can reimplement it virtual functions:

      @
      //For a mouse press and release event
      virtual void mousePressEvent ( QMouseEvent * e )
      virtual void mouseReleaseEvent ( QMouseEvent * e )
      @

      It's very easy.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sorin
        wrote on last edited by
        #3

        At first that was my logic too but mouseReleaseEvent is not triggered for the above behaviour :)

        There are only 10 types of people in the world: Those who understand binary, and those who don't

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stukdev
          wrote on last edited by
          #4

          Maybe you can reimplement virtual bool event ( QEvent * event ) and look what event is generate when you press outside the button.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sorin
            wrote on last edited by
            #5

            @bool MyToolButton::event(QEvent event)
            {
            qDebug( (char
            )QString::number( event->type()).data() );
            return QToolButton::event( event );
            }@

            I don't get any event :( when I press outside my button( with the menu triggered )

            There are only 10 types of people in the world: Those who understand binary, and those who don't

            1 Reply Last reply
            0
            • S Offline
              S Offline
              stukdev
              wrote on last edited by
              #6

              When you say 'press outside the button' what you mean? What object is pressed?

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Lord
                wrote on last edited by
                #7

                I feel when you will click on ToolButton your InstantPopup will get in focus and when you will click out side it will go out of focus or deactivate. Try to catch event when deactivates.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Sorin
                  wrote on last edited by
                  #8

                  Customized my QMenu and on hide event emited a signal to my button. Thanks for help ;)

                  There are only 10 types of people in the world: Those who understand binary, and those who don't

                  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