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. What is Qt's macro "Q_OVERRIDE" used for?
Forum Updated to NodeBB v4.3 + New Features

What is Qt's macro "Q_OVERRIDE" used for?

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

    I find this macro by accident. By curiosity, I want to know how this macro used, better to give me a code snippet.

    我们自己的论坛:http://qtdream.com
    擅长三维角色仿真动画。

    aha_1980A 1 Reply Last reply
    0
    • jiancaiyangJ jiancaiyang

      I find this macro by accident. By curiosity, I want to know how this macro used, better to give me a code snippet.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @jiancaiyang,

      where did you find this macro?

      I only know Q_DECL_OVERRIDE and this was used to introduce the C++11 override keyword while keeping compatibility to non-C++11 compilers.

      On a non-C++11 compiler it is defined as nothing. Nowadays (Qt 5.7+) C++11 is always required and the macro is gradually replaced with override.

      Regards.

      Qt has to stay free or it will die.

      jiancaiyangJ 1 Reply Last reply
      1
      • aha_1980A aha_1980

        Hi @jiancaiyang,

        where did you find this macro?

        I only know Q_DECL_OVERRIDE and this was used to introduce the C++11 override keyword while keeping compatibility to non-C++11 compilers.

        On a non-C++11 compiler it is defined as nothing. Nowadays (Qt 5.7+) C++11 is always required and the macro is gradually replaced with override.

        Regards.

        jiancaiyangJ Offline
        jiancaiyangJ Offline
        jiancaiyang
        wrote on last edited by
        #3

        @aha_1980
        at /Qt5.10.0/5.10.0/clang_64/lib/QtCore.framework/Headers/qobjectdefs.h:117

        You can find this macro.
        But this macro has one argument, I guess it is not used to be compatible with STD C++ 11 override.

        我们自己的论坛:http://qtdream.com
        擅长三维角色仿真动画。

        1 Reply Last reply
        0
        • Paul ColbyP Offline
          Paul ColbyP Offline
          Paul Colby
          wrote on last edited by
          #4

          The macro was added in 6c54e10. Looks like it evaluates to nothing, and was intended to provide meta data for auto-documenting tools?

          Seems it never got used beyond a couple of properties in QTextBrowser? https://github.com/qt/qtbase/search?utf8=✓&q=Q_OVERRIDE&type=

          1 Reply Last reply
          2

          • Login

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