Note that there are some explanatory texts on larger screens.

plurals
  1. POQt pure virtual function error
    primarykey
    data
    text
    <p>I'm tring to create an interface with Qt to oblige any subclass to implements two main methods set and get title. But when I try to compile it I get a weird error message that says something about qt_check_for_QOBJECT_macro and staticMetaObject. In mainwindow.cpp I have to cast any page to the interface so I can rely on getter and setter methods. I don't see any other way to do that.</p> <p>this is my code:</p> <pre><code>//IPage.h #ifndef IPAGE_H #define IPAGE_H #include &lt;QString&gt; class IPage { public: virtual QString title()=0; virtual void setTitle(QString t)=0; }; #endif // IPAGE_H //buildings.h: #ifndef BUILDINGS_H #define BUILDINGS_H #include "IPage.h" #include &lt;QDialog&gt; class Buildings : public IPage, public QDialog { Q_OBJECT private: QString m_title; //stuff... }; #endif //buildings.cpp //stuff... void Buildings::setTitle(QString t) { m_title = t; setWindowTitle(t); } QString Buildings::title() { return m_title; } //mainwindow.cpp: QMdiSubWindow *MainWindow::findChild(const QString &amp;title) { foreach (QMdiSubWindow *window, mdiArea-&gt;subWindowList()) { IPage *child = qobject_cast&lt;IPage *&gt;(window-&gt;widget()); /*line 178*/ if (child-&gt;title() == title) return window; } return 0; } </code></pre> <p>and I get this error message when I compile my code:</p> <pre><code>In file included from c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qabstractanimation.h:45, from c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/QtCore:3, from c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui/QtGui:3, from mainwindow.cpp:1: c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qobject.h: In function 'T qobject_cast(QObject*) [with T = IPage*]': mainwindow.cpp:178: instantiated from here c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qobject.h:378: error: 'class IPage' has no member named 'qt_check_for_QOBJECT_macro' c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qobject.h:380: error: 'class IPage' has no member named 'staticMetaObject' mingw32-make.exe[1]: Leaving directory `D:/Dropbox/Programmi/Qt/Scadenziario' mingw32-make.exe[1]: *** [build/o/mainwindow.o] Error 1 mingw32-make.exe: *** [debug] Error 2 01:23:26: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2. Error while building project scadenziario (target: Desktop) When executing build step 'Make' </code></pre> <p>I can't understand error message. I tried to google it, but I can't find any useful informations. Any help will be appreciated, thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload