Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. EventHandling
Qt 6.11 is out! See what's new in the release blog

EventHandling

Scheduled Pinned Locked Moved Brainstorm
13 Posts 2 Posters 5.4k 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.
  • M Offline
    M Offline
    mvenkat061
    wrote on last edited by
    #4

    I dont want any event on window click .
    I need event on mouse click on any widget like button , check box ..
    and i need event info like event generate widget id, state ..etc..

    can you please help me.

    Thank you
    Regard
    Venkat

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      Then you should take a look at the eventFilter function. Do you really need that level of details ? If so, why ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mvenkat061
        wrote on last edited by
        #6

        Thank you,
        yes i need all info about event because the existing GUI application design is such a way that,
        each events have some set of actions to excite based on some preconditions.

        Ex: Event ID = button1
        precondition = "read text on button2
        Action = if precondition oK then write text on button3.

        so all events, preconditions and Actions are configurable.
        Each time will check event Id which is return from TRT_GETINPUT(..) with configuration events if both are matching then we check precondition and perform action.

        so that why i need a function which return event info.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #7

          AFAIK you can't match that pattern without creating e.g. your own events with these parameters. Or maybe a state machine.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mvenkat061
            wrote on last edited by
            #8

            hi,
            Actually eventID and precondition and action is not pattren.
            Actual Config format is
            [event]
            EventId = button1 //Object ID
            [Precondition]
            ObjectID = button2 //object id for precondition
            Attribut = text // read text on button2

            [Action]
            precondition value = Hello //if text on button is hello
            [API]
            objectId = button3
            action = 3 /
            Argumet = hello /// set text "hello" on button 3 ; we have set of function 3 equivalent to set text.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mvenkat061
              wrote on last edited by
              #9

              EventFilter is called for mouse button press on button object.

              i have added installEventFilter in constructor.?

              Can we need to include any .h or any thing in .pro file
              my code is:

              In .h

              bool eventFilter(QObject *object, QEvent *event);

              in .cpp

              mainwindow :: mainwindow(....)
              {
              button->installEventfilter(this);
              }
              bool mainwindow::eventFilter(QObject *object, QEvent *event)
              {
              if(event->type() == QEvent::MouseButtonPress)
              {
              label->settext("hello");
              }
              }
              can you plz help me how work with event filter

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mvenkat061
                wrote on last edited by
                #10

                hi
                bool eventfilter(Qobject* , QEvent* );
                is working if i create a project with base class of Qwidget but it is not working if i create project with base class of QMainWindow.

                Why this is any reason for it?
                How can make it work for base class Qmainwindow.

                Thank you
                Venkat

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  QMainWindow is a way more complex widget (docks/central widget etc…) You may have to install your event filter on multiple widgets.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mvenkat061
                    wrote on last edited by
                    #12

                    hi,
                    I have install event filter with function "button->installEventFilter(this)"

                    i am try to install on button

                    i am installing event filter after setupUi(..);

                    i am not getting window after run the program.
                    i am getting message like "The program has unexpectedly finished"
                    and " c:\Qt_practice\mouse_event.exe existed with code -1073741819".

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      What does a run through the debugger tells you ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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