Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. can the moc compile a class flagged as Q_OBJECT in Visual Studio Express 2017 ?

can the moc compile a class flagged as Q_OBJECT in Visual Studio Express 2017 ?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
mocvisualstudioqmlc++
4 Posts 2 Posters 1.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.
  • Q Offline
    Q Offline
    Quentin91
    wrote on 2 May 2019, 09:33 last edited by Quentin91 5 Feb 2019, 10:04
    #1

    I wrote a simple class herited from QObject in my main cpp file but can't instanciate it in the main.

    note that everything is compiling fine if I only define the class Anchor but don't use it.
    Here's the code

    #include <QtGui/qguiapplication.h>
    
    #include <QtQml/qqmlengine.h>
    #include <QtQml/qqmlapplicationengine.h>
    
    #include <QtCore/qplugin.h>
    #include <QtCore/qcompilerdetection.h.h>
    #include <QtCore/qvariant.h>
    #include <QtCore/qmetaobject.h>
    
    #include <QtQuick/qquickview.h>
    
     
    class Anchor :public QObject
    {
         Q_OBJECT
         Q_PROPERTY(QString testStr READ getStr WRITE setStr NOTIFY strChanged)
    public:
         Anchor(){   TRACE_DEBUG("Anchor CTOR")   }
         Q_INVOKABLE void clicked(){
               TRACE_DEBUG("I ain't doin nothin")
         }
    };
    
    int main(int argc, char** argv){
    
         Anchor anchor;
         return 0;
    }
    

    Here are the errors :
    the little
    E2512 : the argument of functionality test macro has to be a simple identifier 2 times
    and
    LNK2001 : unresolve extern symbol "public virtual int __cdecl Anchor ::qt_metacall((enum QMetaObject ::Call,int,void**)(?qt_metacall@Anchar@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)

    LNK2001 : unresolve extern symbol "public virtual struct QMetaObject const* __cdecl Anchor ::metaObject(void) const"(?metaObject@Anchar@@UEBAPEBUQQMetaObject@@XZ)

    and another one about metacast, same style.

    So I guess that my solution/project can't deal with meta objects ? I've seen that it's not obvious that Visual Studio Express (2017) can use the MOC. Is it possible ?

    if(possible){How(?);}
    

    ps : I would like to use another IDE, use CMake, code on linux. But I can't. That's visual studio and I'm lucky to use 2017 instead of 2010

    R 1 Reply Last reply 2 May 2019, 13:44
    0
    • Q Quentin91
      2 May 2019, 09:33

      I wrote a simple class herited from QObject in my main cpp file but can't instanciate it in the main.

      note that everything is compiling fine if I only define the class Anchor but don't use it.
      Here's the code

      #include <QtGui/qguiapplication.h>
      
      #include <QtQml/qqmlengine.h>
      #include <QtQml/qqmlapplicationengine.h>
      
      #include <QtCore/qplugin.h>
      #include <QtCore/qcompilerdetection.h.h>
      #include <QtCore/qvariant.h>
      #include <QtCore/qmetaobject.h>
      
      #include <QtQuick/qquickview.h>
      
       
      class Anchor :public QObject
      {
           Q_OBJECT
           Q_PROPERTY(QString testStr READ getStr WRITE setStr NOTIFY strChanged)
      public:
           Anchor(){   TRACE_DEBUG("Anchor CTOR")   }
           Q_INVOKABLE void clicked(){
                 TRACE_DEBUG("I ain't doin nothin")
           }
      };
      
      int main(int argc, char** argv){
      
           Anchor anchor;
           return 0;
      }
      

      Here are the errors :
      the little
      E2512 : the argument of functionality test macro has to be a simple identifier 2 times
      and
      LNK2001 : unresolve extern symbol "public virtual int __cdecl Anchor ::qt_metacall((enum QMetaObject ::Call,int,void**)(?qt_metacall@Anchar@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)

      LNK2001 : unresolve extern symbol "public virtual struct QMetaObject const* __cdecl Anchor ::metaObject(void) const"(?metaObject@Anchar@@UEBAPEBUQQMetaObject@@XZ)

      and another one about metacast, same style.

      So I guess that my solution/project can't deal with meta objects ? I've seen that it's not obvious that Visual Studio Express (2017) can use the MOC. Is it possible ?

      if(possible){How(?);}
      

      ps : I would like to use another IDE, use CMake, code on linux. But I can't. That's visual studio and I'm lucky to use 2017 instead of 2010

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 2 May 2019, 13:44 last edited by
      #2

      @Quentin91
      It seems that the moc output source file isn't compiled into your executable.
      Do you have the Qt VS Addin installed?

      --- 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

      Q 1 Reply Last reply 2 May 2019, 14:35
      0
      • R raven-worx
        2 May 2019, 13:44

        @Quentin91
        It seems that the moc output source file isn't compiled into your executable.
        Do you have the Qt VS Addin installed?

        Q Offline
        Q Offline
        Quentin91
        wrote on 2 May 2019, 14:35 last edited by
        #3

        @raven-worx I don't think so. i will try to download it and install it on my dev computer. But I've seen that the Express version of VS doesn't support it... probably.

        I'll try it, then try to use qmake and maybe a this point I'll get the professionnal version.

        Also, I'll edit my question, I'm using QtCreator to compile some QML. Maybe I can use it for the Meta Objects too ?

        R 1 Reply Last reply 2 May 2019, 14:42
        0
        • Q Quentin91
          2 May 2019, 14:35

          @raven-worx I don't think so. i will try to download it and install it on my dev computer. But I've seen that the Express version of VS doesn't support it... probably.

          I'll try it, then try to use qmake and maybe a this point I'll get the professionnal version.

          Also, I'll edit my question, I'm using QtCreator to compile some QML. Maybe I can use it for the Meta Objects too ?

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 2 May 2019, 14:42 last edited by
          #4

          @Quentin91 said in can the moc compile a class flagged as Q_OBJECT in Visual Studio Express 2017 ?:

          But I've seen that the Express version of VS doesn't support it... probably.

          plugin support was added in recent versions of VS Community.

          --- 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
          0

          2/4

          2 May 2019, 13:44

          • Login

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