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. Registering custom event types
QtWS25 Last Chance

Registering custom event types

Scheduled Pinned Locked Moved Solved General and Desktop
eventevent loop
5 Posts 2 Posters 2.2k 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.
  • K Offline
    K Offline
    kshegunov
    Moderators
    wrote on 13 Feb 2016, 10:45 last edited by
    #1

    Hello,
    Is it safe to register custom event types before main()? I have the code in a .so, so I'm doing this in the header:

    class QMpiEvent : public QEvent
    {
    	Q_GADGET
    
    public:
    	QMpiEvent(Type, QtMpi::NodeId);
    
    	static const Type NodeStarting;
    	static const Type NodeExiting;
    };
    

    And then I register the events in the .cpp:

    const QEvent::Type QMpiEvent::NodeStarting = static_cast<QEvent::Type>(QEvent::registerEventType());
    const QEvent::Type QMpiEvent::NodeExiting = static_cast<QEvent::Type>(QEvent::registerEventType());
    

    Am I supposed to do the registration after the QCoreApplication has been initialized?

    Kind regards.

    Read and abide by the Qt Code of Conduct

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Feb 2016, 23:33 last edited by
      #2

      Hi,

      Looking at the implementation of registerEventType, it seems you can call it before instantiating the QCoreApplication.

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

      K 1 Reply Last reply 13 Feb 2016, 23:36
      0
      • S SGaist
        13 Feb 2016, 23:33

        Hi,

        Looking at the implementation of registerEventType, it seems you can call it before instantiating the QCoreApplication.

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 13 Feb 2016, 23:36 last edited by
        #3

        @SGaist
        Right, I peaked at it as well, but was unsure whether I might have missed something. :)

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 13 Feb 2016, 23:38 last edited by
          #4

          Doesn't seem so :) Or we both missed it :D

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

          K 1 Reply Last reply 13 Feb 2016, 23:40
          0
          • S SGaist
            13 Feb 2016, 23:38

            Doesn't seem so :) Or we both missed it :D

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 13 Feb 2016, 23:40 last edited by
            #5

            @SGaist
            When I finish up my code the obvious run and if it crashes test will tell for sure.
            Unfortunately, the documentation is very cryptic of such issues ... :)

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0

            1/5

            13 Feb 2016, 10:45

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved