Error while using qmlRegisterType
-
Hi
I am trying to expose a C++ class to qml and I have used the following line of code in main.cpp after including the class header.
qmlRegisterType<FlightMapSettings>("FlightMapSettings",1,0,"MapSettings");But I get these errors:
...../Qt5.6.0/5.6/gcc_64/include/QtQml/qqmlprivate.h:102: error: use of deleted function 'QQmlPrivate::QQmlElement<FlightMapSettings>::QQmlElement()'
void createInto(void *memory) { new (memory) QQmlElement<T>; }..../Qt5.6.0/5.6/gcc_64/include/QtQml/qqmlprivate.h:93: error: no matching function for call to 'FlightMapSettings::FlightMapSettings()'
^What could be the possible issue?
Thanks
-
Hi! Please show us said header file.
-
Hi! Please show us said header file.
@Wieland
#include <QObject> #include <QStringList> class FlightMapSettings : public QWidget { Q_OBJECT public: FlightMapSettings(QWidget *parent); signals: void mapProviderChanged(const QString& mapProvider); void mapTypesChanged(const QStringList& mapTypes); }; -
First of all ,
#include <QWidget>is missing. Second is the missing default constructor:explicit FlightMapSettings(QWidget *parent = Q_NULLPTR); -
BTW, why do you register a QWidget derived class to the QML engine?
-
BTW, why do you register a QWidget derived class to the QML engine?