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. [Solved] Compiler report error after adding Q_OBJECT in header file
Forum Updated to NodeBB v4.3 + New Features

[Solved] Compiler report error after adding Q_OBJECT in header file

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

    I wrote a class which inherit QWizardPage with UI form(*.ui).

    @
    #include "QWizardPage.h"

    namespace Ui {
    class PageReport;
    }

    class PageReport : public QWizardPage
    {
    Q_OBJECT
    public:
    ...... //other impelementation
    };
    @

    It works well. But when I want to share the UI form with some other wizard pages. I wrote another class which inherit the class I wrote previously. So that I can reuse the UI form and some common functions in the sub-class.

    @
    #include "pagereport.h"

    class PageReportDone : public PageReport
    {
    Q_OBJECT // it generated some error
    public:
    ...... //other impelementation
    };
    @

    Here is the problem, the compiler reported the following error:
    @
    error: undefined reference to `vtable for PageReportDone'
    @

    If I remove the Q_OBJECT from the header file of PageReportDone, the compiler would work. But I am afraid if there would be some disorder, bugs or some invisible problem afrer removing the Q_OBJECT macro.

    How can I reuse the form with all QObject function working correctly? or I can just remove the Q_OBJECT without worrying about the QObject related function does not work.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Rerun qmake after adding of remove Q_OBJECT macros and make sure the header is listed in HEADERS

      1 Reply Last reply
      0
      • D Offline
        D Offline
        donitaroid
        wrote on last edited by
        #3

        Thank you. This problem was solved after rerun qmake. :-)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          Be sure and edit the initial thread to add [Solved] to the title. Thanks!

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          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