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. qt - undefined reference to `vtable for myObj' in qt console application - signals and slots
Forum Updated to NodeBB v4.3 + New Features

qt - undefined reference to `vtable for myObj' in qt console application - signals and slots

Scheduled Pinned Locked Moved Unsolved General and Desktop
qobjectmacroclassvtableqt 5.7
11 Posts 7 Posters 8.1k Views 3 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.
  • H Offline
    H Offline
    hskoglund
    wrote on 25 Jan 2017, 03:09 last edited by hskoglund
    #2

    Hi, the Q_OBJECT macro in your class declaration needs to be processed by the moc compiler. Easiest is to move your class declaration into your main.h.
    EDIT: forgot probably you don't have a main.h yet, if so, just create it and put the class declaration inside it. And don't forget to #include main.h in your main.cpp :-)

    1 Reply Last reply
    1
    • Y Offline
      Y Offline
      yuvaram
      wrote on 25 Jan 2017, 04:12 last edited by yuvaram
      #3

      Hi CybeX,
      I have experimented your program. All the syntax are perfect, there is a issue with CLASS name (myObj).
      with class name myObj i m getting linker error.
      But by changing the class name and building there is no error. So may be there is some dependency issue with class name myObj.
      change it to myObj1 and try.

      Yuvaram Aligeti
      Embedded Qt Developer
      : )

      D 1 Reply Last reply 25 Jan 2017, 05:55
      0
      • Y yuvaram
        25 Jan 2017, 04:12

        Hi CybeX,
        I have experimented your program. All the syntax are perfect, there is a issue with CLASS name (myObj).
        with class name myObj i m getting linker error.
        But by changing the class name and building there is no error. So may be there is some dependency issue with class name myObj.
        change it to myObj1 and try.

        D Offline
        D Offline
        Devopia53
        wrote on 25 Jan 2017, 05:55 last edited by Devopia53
        #4

        @yuvaram

        Hi.

        You can just add the following line in main.cpp:

        [...]
        #include "main.moc"
        
        int main(int argc, char *argv[])
        {
        [...]
        
        

        and then run qmake.

        1 Reply Last reply
        1
        • Y Offline
          Y Offline
          yuvaram
          wrote on 25 Jan 2017, 06:37 last edited by
          #5

          @Devopia53
          Thank for correcting.

          But after adding #include "main.moc", (run qmake is also done) following error while building.

          Error: dependent 'debug\main.moc' does not exist.

          Yuvaram Aligeti
          Embedded Qt Developer
          : )

          D 1 Reply Last reply 25 Jan 2017, 07:46
          0
          • Y yuvaram
            25 Jan 2017, 06:37

            @Devopia53
            Thank for correcting.

            But after adding #include "main.moc", (run qmake is also done) following error while building.

            Error: dependent 'debug\main.moc' does not exist.

            D Offline
            D Offline
            Devopia53
            wrote on 25 Jan 2017, 07:46 last edited by
            #6

            @yuvaram

            Really? :(

            I'm works fine.
            If so, you can delete all of the previously built directories and then save main.cpp and rebuild all. Also, check where the main.moc file is generated.

            Good luck!.

            1 Reply Last reply
            1
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 26 Jan 2017, 00:03 last edited by
              #7

              Hi,

              If you really want to use that technique, the moc include should be the last line of main.cpp file

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • Y Offline
                Y Offline
                yuvaram
                wrote on 26 Jan 2017, 01:28 last edited by
                #8

                Hi ,
                main.moc file is not generating.

                Yuvaram Aligeti
                Embedded Qt Developer
                : )

                M D 2 Replies Last reply 26 Jan 2017, 07:32
                1
                • Y yuvaram
                  26 Jan 2017, 01:28

                  Hi ,
                  main.moc file is not generating.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 26 Jan 2017, 07:32 last edited by mrjj
                  #9

                  @yuvaram
                  Hi
                  For less pain. just use a .h file. :)

                  Delete the build folder and rebuild all.

                  1 Reply Last reply
                  1
                  • Y yuvaram
                    26 Jan 2017, 01:28

                    Hi ,
                    main.moc file is not generating.

                    D Offline
                    D Offline
                    Devopia53
                    wrote on 26 Jan 2017, 07:45 last edited by
                    #10

                    @yuvaram

                    If so, compile it with Network Download Example, which is officially available from Qt.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Stonge357
                      Banned
                      wrote on 8 Jun 2018, 10:28 last edited by
                      #11
                      This post is deleted!
                      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