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. Error while using qmlRegisterType
Qt 6.11 is out! See what's new in the release blog

Error while using qmlRegisterType

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 5.0k 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.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Please show us said header file.

      saitejS 1 Reply Last reply
      0
      • ? A Former User

        Hi! Please show us said header file.

        saitejS Offline
        saitejS Offline
        saitej
        wrote on last edited by
        #3

        @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);
        };
        
        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by A Former User
          #4

          First of all , #include <QWidget> is missing. Second is the missing default constructor:

          explicit FlightMapSettings(QWidget *parent = Q_NULLPTR);
          
          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            BTW, why do you register a QWidget derived class to the QML engine?

            saitejS 1 Reply Last reply
            0
            • ? A Former User

              BTW, why do you register a QWidget derived class to the QML engine?

              saitejS Offline
              saitejS Offline
              saitej
              wrote on last edited by saitej
              #6

              @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!!

              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