Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
4.7.4, 4.8.5
-
None
Description
Base class:
human.h
#include <QObject> class Human : public QObject { Q_OBJECT Q_ENUMS(Gender) public: Human() : QObject() {} enum Gender { Male, Female }; };
Derived class
female.h
#include "human.h" class Female : public Human { // Q_OBJECT compile error! Q_ENUMS(Brain) public: enum Brain { Smart, Stupid }; Female() : Human() {} };
Type registration and qml viewer run:
main.cpp
#include <QApplication> #include "qmlapplicationviewer.h" #include "female.h" #include <qdeclarative.h> Q_DECL_EXPORT int main(int argc, char *argv[]) { QScopedPointer<QApplication> app(createApplication(argc, argv)); qmlRegisterType<Female>("factory.inc.models", 1, 0, "Female"); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/test/main.qml")); viewer.showExpanded(); return app->exec(); }
call scope
main.qml
import QtQuick 1.0 import factory.inc.models 1.0 Rectangle { width: 360 height: 360 Component.onCompleted: { console.log(Female.Male); // 0 console.log(Female.Female); // 1 console.log(Female.Smart); // undefined console.log(Female.Stupid); // undefined } }
update:
adding Q_OBJECT to derived class give me compile (linking) error.
After asking some people, I delete build folder with make files and build again. Problem gone.
So I think this problem related with QtCreator or general qt build system (it's repeated in test project too).
Attachments
Issue Links
- duplicates
-
QTBUG-26426 adding/removing Q_OBJECT requires explicit invocation of qmake
- Closed