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. Why we use "QT_USE_NAMESPACE" in some of Qt Programs?
Forum Updated to NodeBB v4.3 + New Features

Why we use "QT_USE_NAMESPACE" in some of Qt Programs?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 2.5k Views 2 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.
  • P Offline
    P Offline
    PooyaSis
    wrote on last edited by
    #1

    Hi
    In many cases I've seen that people use "QT_USE_NAMESPACE".
    I googled it, and couldn't find anything..
    What's the purpose of "QT_USE_NAMESPACE" , and why do we use it?
    Why there is nothing about it around!!!! :/

    1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @PooyaSis

      You can compile Qt yourself within a namespace, e.g. to use a diffent Qt version within a plugin than the program that loads the plugin uses. More information here: https://wiki.qt.io/Qt_In_Namespace

      I have not seen QT_USE_NAMESPACE so far, only QT_BEGIN_NAMESPACE and QT_END_NAMESPACE.

      Where did you see QT_USE_NAMESPACE?

      Qt has to stay free or it will die.

      1 Reply Last reply
      4
      • P Offline
        P Offline
        PooyaSis
        wrote on last edited by
        #3

        @PooyaSis said in Why we use "QT_USE_NAMESPACE" in some of Qt Programs?:

        QT_USE_NAMESPACE

        Thanks a lot.
        It was here in this example:

        http://doc.qt.io/qt-5/qtserialport-cwriterasync-serialportwriter-cpp.html

        1 Reply Last reply
        0
        • F Offline
          F Offline
          FloatFlower.Huang
          wrote on last edited by
          #4

          @PooyaSis
          In Qt source code, you can check qtbase/src/corelib/global/qglobal.h
          You will find that

          #define QT_USE_NAMESPACE using namespace ::QT_NAMESPACE;
          

          Here is the source code, you can find it at line 133
          https://github.com/qt/qtbase/blob/5.10/src/corelib/global/qglobal.h

          1 Reply Last reply
          1

          • Login

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