Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [SOLVED] How do you create a new event?

    General and Desktop
    4
    7
    1173
    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.
    • J
      Jose Antonio last edited by Jose Antonio

      I would know like to do a new event to use QEvent::user

      In particular, how do you do an event, when you change a variable?

      JKSH 1 Reply Last reply Reply Quote 0
      • JKSH
        JKSH Moderators @Jose Antonio last edited by JKSH

        @Jose-Antonio said:

        I would know like to do a new event to use QEvent::user

        In particular, how do you do an event, when you change a variable?

        Hi, and welcome to the Qt Dev Net!

        For detecting change of variables, you should use Signals and Slots instead of events. That way, you don't need to subclass of QEvent.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply Reply Quote 1
        • J
          Jose Antonio last edited by

          Firstly, thanks for your help, but I have a problem I don't know very well QEvent::user, and I need create my own event with QEvent for a interruption.

          Thanks for all.

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            Hi,
            you need to create a custom class that inherits QEvent and register it with QEvent::registerEventType(). You can then post events with QCoreApplication::sendEvent() or QCoreApplication::postEvent().

            1 Reply Last reply Reply Quote 1
            • J
              Jose Antonio last edited by

              And the condition of the event, in my case when variable = 1 wherein do it carey?

              1 Reply Last reply Reply Quote 0
              • ?
                A Former User last edited by

                You can put it in a member variable of your event class:

                class MyEvent: public QEvent
                {
                    // ...
                    bool myCondition;
                };
                
                1 Reply Last reply Reply Quote 1
                • N
                  Neer Banned last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post