Important: Please read the Qt Code of Conduct -

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.


    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?


  • Hi! Please show us said header file.

  • @Wieland

    #include <QObject>
    #include <QStringList>
    class FlightMapSettings : public QWidget
        FlightMapSettings(QWidget *parent);
    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?

  • @Wieland

    I have given the default constructor and it works. It was a copy paste mistake and I have removed the QWidget.

    Thanks a lot!!

Log in to reply