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. LabRat 'Gotcha' moc not seeing namespace.
Forum Updated to NodeBB v4.3 + New Features

LabRat 'Gotcha' moc not seeing namespace.

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 5.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.
  • D Offline
    D Offline
    Dusty
    wrote on last edited by
    #1

    Hello everyone!
    I am new at this, so please feel free to clout me one over the head if I'm mistaken here!

    I just found out that having a macro declared for a namespace seems to cause the moc compiler some grief.

    eg;

    @#define MY_BEGIN_NAMESPACE namespace MyNamespace {
    #define MY_END_NAMESPACE }@

    implementation:
    @#ifndef MY_TOOLS_H
    #define MY_TOOLS_H

    #include <QObject>

    #include "CommonDefinitionsQT.h"

    MY_BEGIN_NAMESPACE

    class MyTools : public QObject
    {
    ...
    }

    MY_END_NAMESPACE
    @

    causes:
    error C2653: 'MyTools' : is not a class or namespace name

    Copied from the moc source file:
    @// enum data: key, value
    79, uint(MyTools::CRC_None),
    88, uint(MyTools::CRC_8_Bit),
    @

    As you can see, I have a few Q_ENUMS() declared.
    As it seems, it is not appending the namespace to the 'MyTools class or adding a 'using namespace' declaration to the moc file.

    I'm using the latest version of QT with the Visual Studio edition.

    By the way, I got this nifty idea from the QXT library where they seem to be using this just fine, so what am I doing wrong?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      without changing your defines, ... try this
      @
      #ifndef MY_TOOLS_H
      #define MY_TOOLS_H

      #include <QObject>

      #include "CommonDefinitionsQT.h"

      MY_BEGIN_NAMESPACE
      class MyTools;
      MY_END_NAMESPACE

      class MyTools : public QObject
      {
      ...
      };
      #endif // MY_TOOLS_H

      @

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lyuts
        wrote on last edited by
        #3

        You missed ";" at the end of class definition.

        I'm a rebel in the S.D.G.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          corrected immediately :p

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dusty
            wrote on last edited by
            #5

            Thanks chetankjain for your response, I will give this a try over the weekend.

            Regarding the ";" My apologies lyuts, this was just an oversight while typing into the forum, my code of course contains a ";" at the end of the class.

            I will post a reply once I'm in a position to compile.

            Cheers.

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #6

              its funny actually I too posted my code with a missing ; at the end of the class definition too, but corrected immediately :)

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Dusty
                wrote on last edited by
                #7

                Well I recompiled and it works like a charm!.

                Thanks for your help on the subject. I knew it would be a rookie mistake :)

                I reckon the ";" is one of the most time wasting characters in the whole c language, I have spent hours tracking down these little you know whats... but I guess that why we like it!

                Cheers.

                1 Reply Last reply
                0
                • ? This user is from outside of this forum
                  ? This user is from outside of this forum
                  Guest
                  wrote on last edited by
                  #8

                  good it worked :)

                  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