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. Importing namespaces from other projects
Qt 6.11 is out! See what's new in the release blog

Importing namespaces from other projects

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 319 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.
  • E Offline
    E Offline
    emazed
    wrote on last edited by
    #1

    Hello,
    i'd like to use enum defined in a referred project, inside a namespaces.
    I have a project 'referred.pri', which is included in main project 'main.pro'. Then in 'referred' project i have and header file with enums defined in a namespace.

    #ifndef referred_H
    #define referred_H
    
    #include <QObject>
    //...
    
    namsepace ns1 {
      Q_NAMESPACE
       myenum enum1 {
         item1,
         intem2,
       };
      Q_ENUM_NS(enum1)
    }
    // ...
    

    then i my main header 'main.h'

    // ...
    #inlcude referred.h
    
    using namespace ns1;   // error: expected namespace name
    // ...
    

    why i can't use namespace defined in other header of referred project? what am i missing??

    Thank you

    VRoninV 1 Reply Last reply
    0
    • E emazed

      Hello,
      i'd like to use enum defined in a referred project, inside a namespaces.
      I have a project 'referred.pri', which is included in main project 'main.pro'. Then in 'referred' project i have and header file with enums defined in a namespace.

      #ifndef referred_H
      #define referred_H
      
      #include <QObject>
      //...
      
      namsepace ns1 {
        Q_NAMESPACE
         myenum enum1 {
           item1,
           intem2,
         };
        Q_ENUM_NS(enum1)
      }
      // ...
      

      then i my main header 'main.h'

      // ...
      #inlcude referred.h
      
      using namespace ns1;   // error: expected namespace name
      // ...
      

      why i can't use namespace defined in other header of referred project? what am i missing??

      Thank you

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @emazed said in Importing namespaces from other projects:

      #inlcude referred.h

      I suppose it was #inlcude "referred.h". Can you use anything else from referred.h? Looks to me like mainh can't see referred.h

      "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
      0
      • E Offline
        E Offline
        emazed
        wrote on last edited by
        #3

        yes sorry, it is #include "referred.h".
        I found that another different header file included in 'main.h', that had same two lines at beginning:

        #ifndef referred_H
        #define referred_H
        

        this is because i copied this file directly from 'referred.h', and forgot to change first two lines. This caused the exclusion of entire content of referred.h file. Sorry.

        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