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. [SOLVED] How do you create a new event?
QtWS25 Last Chance

[SOLVED] How do you create a new event?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.5k 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.
  • J Offline
    J Offline
    Jose Antonio
    wrote on last edited by Jose Antonio
    #1

    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?

    JKSHJ 1 Reply Last reply
    0
    • J 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?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #2

      @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
      1
      • J Offline
        J Offline
        Jose Antonio
        wrote on last edited by
        #3

        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
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          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
          1
          • J Offline
            J Offline
            Jose Antonio
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

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

              class MyEvent: public QEvent
              {
                  // ...
                  bool myCondition;
              };
              
              1 Reply Last reply
              1
              • N Offline
                N Offline
                Neer
                Banned
                wrote on last edited by
                #7
                This post is deleted!
                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