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. custom events?
Forum Updated to NodeBB v4.3 + New Features

custom events?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 2.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.
  • J Offline
    J Offline
    JoeJoe_000
    wrote on last edited by
    #1

    Hello I have an object. When an this object is constructed I would like an even to occur.

    I've setup the this->installEventFilter(parent); argument in this object and I have also written a function of eventFilter(QObject *obj, QEvent *evt) to process the events.

    Whats a problem for me is how do I setup a custom even so i can send it to the evenFilter() function.

    Is there a good tutorial on setting up custom events?

    JonBJ kshegunovK 2 Replies Last reply
    0
    • J JoeJoe_000

      Hello I have an object. When an this object is constructed I would like an even to occur.

      I've setup the this->installEventFilter(parent); argument in this object and I have also written a function of eventFilter(QObject *obj, QEvent *evt) to process the events.

      Whats a problem for me is how do I setup a custom even so i can send it to the evenFilter() function.

      Is there a good tutorial on setting up custom events?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @JoeJoe_000
      Possibly posting this in the Jobs sub-forum is not the best place? :)

      Did you Google for qt5 custom event? A link like summarises it as just:

      A custom event can be handled by an object. To make a custom event you have to:

      Implement this class's custom event handler (customEvent(…)), so that when an event is sent to an instance of this class, this method will be called to handle the situation.
      Send an event using QApplication::postEvent(…) and give an instance of the class mentioned before as one of the parameters.

      BTW, did you indeed mean a QEvent and not just a signal to emit?

      J.HilkJ J 2 Replies Last reply
      0
      • JonBJ JonB

        @JoeJoe_000
        Possibly posting this in the Jobs sub-forum is not the best place? :)

        Did you Google for qt5 custom event? A link like summarises it as just:

        A custom event can be handled by an object. To make a custom event you have to:

        Implement this class's custom event handler (customEvent(…)), so that when an event is sent to an instance of this class, this method will be called to handle the situation.
        Send an event using QApplication::postEvent(…) and give an instance of the class mentioned before as one of the parameters.

        BTW, did you indeed mean a QEvent and not just a signal to emit?

        J.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @JonB said in custom events?:

        Possibly posting this in the Jobs sub-forum is not the best place? :)

        I agree, jobs is definitely the wrong sub forum.
        Moved to General


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        1
        • J Offline
          J Offline
          JoeJoe_000
          wrote on last edited by
          #4

          Sorry about accidentally posting in jobs section. I must have confused a few open tabs.

          Yes I meant QEvent. I'll reply more on this soon...

          1 Reply Last reply
          0
          • J JoeJoe_000

            Hello I have an object. When an this object is constructed I would like an even to occur.

            I've setup the this->installEventFilter(parent); argument in this object and I have also written a function of eventFilter(QObject *obj, QEvent *evt) to process the events.

            Whats a problem for me is how do I setup a custom even so i can send it to the evenFilter() function.

            Is there a good tutorial on setting up custom events?

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @JoeJoe_000 said in custom events?:

            Hello I have an object. When an this object is constructed I would like an even to occur.

            Either post it manually, or do it from the object's constructor.

            Is there a good tutorial on setting up custom events?

            Nothing to it. Just derive QEvent and add appropriate methods. Register the event type with QEvent::registerEventType on program start (or wherever appropriate).

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            1
            • JonBJ JonB

              @JoeJoe_000
              Possibly posting this in the Jobs sub-forum is not the best place? :)

              Did you Google for qt5 custom event? A link like summarises it as just:

              A custom event can be handled by an object. To make a custom event you have to:

              Implement this class's custom event handler (customEvent(…)), so that when an event is sent to an instance of this class, this method will be called to handle the situation.
              Send an event using QApplication::postEvent(…) and give an instance of the class mentioned before as one of the parameters.

              BTW, did you indeed mean a QEvent and not just a signal to emit?

              J Offline
              J Offline
              JoeJoe_000
              wrote on last edited by
              #6

              @JonB could you link me to the exact source you're using? Is it https://doc.qt.io/qt-5/qevent.html ?

              JonBJ 1 Reply Last reply
              0
              • J JoeJoe_000

                @JonB could you link me to the exact source you're using? Is it https://doc.qt.io/qt-5/qevent.html ?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @JoeJoe_000 said in custom events?:

                @JonB could you link me to the exact source you're using? Is it https://doc.qt.io/qt-5/qevent.html ?

                Sorry, I'm usually very good about pasting my references! I picked that one up from http://programmingexamples.wikidot.com/qt-events, right at the foot of the page. I thought that gave a nicely laid out summary.

                J 1 Reply Last reply
                0
                • JonBJ JonB

                  @JoeJoe_000 said in custom events?:

                  @JonB could you link me to the exact source you're using? Is it https://doc.qt.io/qt-5/qevent.html ?

                  Sorry, I'm usually very good about pasting my references! I picked that one up from http://programmingexamples.wikidot.com/qt-events, right at the foot of the page. I thought that gave a nicely laid out summary.

                  J Offline
                  J Offline
                  JoeJoe_000
                  wrote on last edited by
                  #8

                  @JonB thanks! :D

                  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