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. Qmake did not run moc to generate moc files?
Forum Updated to NodeBB v4.3 + New Features

Qmake did not run moc to generate moc files?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.5k 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by
    #1

    I have a class with Q_OBJECT at the top, like you see below. I was under the impression that when I run qmake,
    it will generate the moc files that are needed to connect signals and slots. Is that not true?
    Currently it is not doing that, and I am getting "missing vtable" errors during the link phase.

    class MyWindowClass : public QMainWindow
    {
            Q_OBJECT
     //...
    }
    
    
    eyllanescE 1 Reply Last reply
    0
    • P Publicnamer

      I have a class with Q_OBJECT at the top, like you see below. I was under the impression that when I run qmake,
      it will generate the moc files that are needed to connect signals and slots. Is that not true?
      Currently it is not doing that, and I am getting "missing vtable" errors during the link phase.

      class MyWindowClass : public QMainWindow
      {
              Q_OBJECT
       //...
      }
      
      
      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by eyllanesc
      #2

      @Publicnamer please provide a minimal and reproducible example. Is myWindowClass class in the main.cpp or in a file like mywindowclass.h?

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      P 1 Reply Last reply
      0
      • eyllanescE eyllanesc

        @Publicnamer please provide a minimal and reproducible example. Is myWindowClass class in the main.cpp or in a file like mywindowclass.h?

        P Offline
        P Offline
        Publicnamer
        wrote on last edited by
        #3

        @eyllanesc
        Why would that main.cpp matter?

        eyllanescE 1 Reply Last reply
        0
        • P Publicnamer

          @eyllanesc
          Why would that main.cpp matter?

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #4

          @Publicnamer If the Q_OBJECT macro is not in main.cpp but in foo.h then MOC creates a file foo_moc.h and linked, but if it is in main.cpp then you must include "main.moc" since it is not linked by qmake. If it is the latter then add #include "main.moc" before int main(...){}

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          P 1 Reply Last reply
          3
          • eyllanescE eyllanesc

            @Publicnamer If the Q_OBJECT macro is not in main.cpp but in foo.h then MOC creates a file foo_moc.h and linked, but if it is in main.cpp then you must include "main.moc" since it is not linked by qmake. If it is the latter then add #include "main.moc" before int main(...){}

            P Offline
            P Offline
            Publicnamer
            wrote on last edited by
            #5

            @eyllanesc I just put #include "main.moc" in main.cpp but it's unclear where to put Q_OBJECT, because everywhere that I try gives an error.

            In file included from /usr/include/aarch64-linux-gnu/qt5/QtCore/qobject.h:46,
                             from /usr/include/aarch64-linux-gnu/qt5/QtCore/qcoreapplication.h:46,
                             from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/qapplication.h:44,
                             from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/QApplication:1,
                             from main.cpp:9:
            main.cpp:12:1: error: expected unqualified-id before ‘public’
             Q_OBJECT
             ^~~~~~~~
            In file included from /usr/include/aarch64-linux-gnu/qt5/QtCore/qglobal.h:105,
                             from /usr/include/aarch64-linux-gnu/qt5/QtGui/qtguiglobal.h:43,
                             from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/qtwidgetsglobal.h:43,
                             from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/qapplication.h:43,
                             from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/QApplication:1,
                             from main.cpp:9:
            main.cpp:12:1: error: expected declaration before end of line
             Q_OBJECT
             ^~~~~~~~
            
            
            eyllanescE 1 Reply Last reply
            0
            • P Publicnamer

              @eyllanesc I just put #include "main.moc" in main.cpp but it's unclear where to put Q_OBJECT, because everywhere that I try gives an error.

              In file included from /usr/include/aarch64-linux-gnu/qt5/QtCore/qobject.h:46,
                               from /usr/include/aarch64-linux-gnu/qt5/QtCore/qcoreapplication.h:46,
                               from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/qapplication.h:44,
                               from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/QApplication:1,
                               from main.cpp:9:
              main.cpp:12:1: error: expected unqualified-id before ‘public’
               Q_OBJECT
               ^~~~~~~~
              In file included from /usr/include/aarch64-linux-gnu/qt5/QtCore/qglobal.h:105,
                               from /usr/include/aarch64-linux-gnu/qt5/QtGui/qtguiglobal.h:43,
                               from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/qtwidgetsglobal.h:43,
                               from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/qapplication.h:43,
                               from /usr/include/aarch64-linux-gnu/qt5/QtWidgets/QApplication:1,
                               from main.cpp:9:
              main.cpp:12:1: error: expected declaration before end of line
               Q_OBJECT
               ^~~~~~~~
              
              
              eyllanescE Offline
              eyllanescE Offline
              eyllanesc
              wrote on last edited by
              #6

              @Publicnamer AGAIN: please provide a minimal and reproducible example

              If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

              P 1 Reply Last reply
              0
              • eyllanescE eyllanesc

                @Publicnamer AGAIN: please provide a minimal and reproducible example

                P Offline
                P Offline
                Publicnamer
                wrote on last edited by
                #7

                @eyllanesc
                One line fixed it. This really should not be so hard to figure out. Maybe better error messages from qmake would help.

                HEADERS += MyWindow.h 
                
                mrjjM 1 Reply Last reply
                0
                • P Publicnamer

                  @eyllanesc
                  One line fixed it. This really should not be so hard to figure out. Maybe better error messages from qmake would help.

                  HEADERS += MyWindow.h 
                  
                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @Publicnamer

                  Well MOC runs on the .h files included in the project so if you didn't
                  include the header file in the .pro file, then MOC would have no
                  idea it has to process it.

                  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