Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Get Event

    General and Desktop
    3
    8
    3640
    Loading More Posts
    • 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
      Sorin last edited by

      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 Reply Quote 0
      • S
        stukdev last edited by

        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 Reply Quote 0
        • S
          Sorin last edited by

          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 Reply Quote 0
          • S
            stukdev last edited by

            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 Reply Quote 0
            • S
              Sorin last edited by

              @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 Reply Quote 0
              • S
                stukdev last edited by

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

                1 Reply Last reply Reply Quote 0
                • L
                  Lord last edited by

                  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 Reply Quote 0
                  • S
                    Sorin last edited by

                    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 Reply Quote 0
                    • First post
                      Last post