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. Purpose of Q_SLOTS, Q_SIGNALS, Q_EMIT, ...
QtWS25 Last Chance

Purpose of Q_SLOTS, Q_SIGNALS, Q_EMIT, ...

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 3.7k 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.
  • beeckscheB Offline
    beeckscheB Offline
    beecksche
    wrote on last edited by beecksche
    #1

    Hi,
    can some explain me the purpose of the Q_SLOTS, Q_SIGNALS, Q_DECL_OVERRIDE and Q_EMIT macros.
    I also can use slots, signals, override and emit to get the same result.

    Do the macros have some advantages?

    Thanks!

    miclandM raven-worxR 2 Replies Last reply
    0
    • beeckscheB beecksche

      Hi,
      can some explain me the purpose of the Q_SLOTS, Q_SIGNALS, Q_DECL_OVERRIDE and Q_EMIT macros.
      I also can use slots, signals, override and emit to get the same result.

      Do the macros have some advantages?

      Thanks!

      miclandM Offline
      miclandM Offline
      micland
      wrote on last edited by
      #2

      @beecksche
      using the "keywords" slots, signals, override and emit may conflict with third party libraries (for example boost::signals) - in this case you can use CONFIG+=no_keywords and use the macros instead of the mentioned keywords.

      1 Reply Last reply
      5
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        @micland is correct but it's missing Q_DECL_OVERRIDE that is just a trick to make it backward compatible. if you use override (which is not a Qt keyword but pure C++) on a compiler that does not support C++11 then it will not compile. Q_DECL_OVERRIDE is defined as override if the compiler supports it otherwise it translate to nothing at all

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        5
        • beeckscheB beecksche

          Hi,
          can some explain me the purpose of the Q_SLOTS, Q_SIGNALS, Q_DECL_OVERRIDE and Q_EMIT macros.
          I also can use slots, signals, override and emit to get the same result.

          Do the macros have some advantages?

          Thanks!

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @beecksche said in Purpose of Q_SLOTS, Q_SIGNALS, Q_EMIT, ...:

          I also can use slots, signals, override and emit to get the same result.

          actually these keywords are also macros mapped to the stated macros of yours. They are just nicer to read.
          As @micland already stated, in case they conflict with other libraries you must use the macros. But it doesn't make any difference, since at the end they are mapped to the same macros an interpreted by moc.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          3

          • Login

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