Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. qmlRegisterType dont' recogized into qml file
Forum Updated to NodeBB v4.3 + New Features

qmlRegisterType dont' recogized into qml file

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 931 Views 3 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.
  • elicatE Offline
    elicatE Offline
    elicat
    wrote on last edited by
    #1

    Hello,
    Now i'm sudy use webengine (into ubuntu 32bit with QT 5.5)
    i have declare in main.cpp

     qmlRegisterType<engineIndexHtml>("PageIndexHtml", 1, 0, "engineIndexHtml");
    

    thi is a class qith file engineIndexHtml.h

    class engineIndexHtml : public QObject
    {
        Q_OBJECT
        Q_PROPERTY(int answerToLife READ answerToLife NOTIFY answerToLifeChanged)
    public:
        explicit engineIndexHtml(QObject *parent = 0);
        int answerToLife() const;
        Q_INVOKABLE void changeAnswerToLife();
    signals:
        void answerToLifeChanged(int answer);
    private:
        int m_answerToLife;
    
    };
    

    and engineIndexHtml.cpp

    #include "engineindexhtml.h"
    
    engineIndexHtml::engineIndexHtml(QObject *parent)
        : QObject(parent),
          m_answerToLife(42)
    {
    }
    
    int engineIndexHtml::answerToLife() const
    {
        return m_answerToLife;
    }
    void engineIndexHtml::changeAnswerToLife()
    {
        m_answerToLife = (int) (m_answerToLife * 8.5f) % 43;
        emit answerToLifeChanged(m_answerToLife);
    }
    

    After i want use object into QML file

    . . . .
    import PageIndexHtml 2.0
    
    Window {
        engineIndexHtml {
            id: oldBeardedMan
            WebChannel.id: "wiseMan"
        }
    

    Why QmlApplicationEngine don't load component and wirte this error ?

    Cannot assign to non-existent property "engineIndexHtml"
    

    The meaning of the message is clear but why? what is missing ?

    Saluti, Gianfranco Elicat

    A raven-worxR 2 Replies Last reply
    0
    • elicatE elicat

      Hello,
      Now i'm sudy use webengine (into ubuntu 32bit with QT 5.5)
      i have declare in main.cpp

       qmlRegisterType<engineIndexHtml>("PageIndexHtml", 1, 0, "engineIndexHtml");
      

      thi is a class qith file engineIndexHtml.h

      class engineIndexHtml : public QObject
      {
          Q_OBJECT
          Q_PROPERTY(int answerToLife READ answerToLife NOTIFY answerToLifeChanged)
      public:
          explicit engineIndexHtml(QObject *parent = 0);
          int answerToLife() const;
          Q_INVOKABLE void changeAnswerToLife();
      signals:
          void answerToLifeChanged(int answer);
      private:
          int m_answerToLife;
      
      };
      

      and engineIndexHtml.cpp

      #include "engineindexhtml.h"
      
      engineIndexHtml::engineIndexHtml(QObject *parent)
          : QObject(parent),
            m_answerToLife(42)
      {
      }
      
      int engineIndexHtml::answerToLife() const
      {
          return m_answerToLife;
      }
      void engineIndexHtml::changeAnswerToLife()
      {
          m_answerToLife = (int) (m_answerToLife * 8.5f) % 43;
          emit answerToLifeChanged(m_answerToLife);
      }
      

      After i want use object into QML file

      . . . .
      import PageIndexHtml 2.0
      
      Window {
          engineIndexHtml {
              id: oldBeardedMan
              WebChannel.id: "wiseMan"
          }
      

      Why QmlApplicationEngine don't load component and wirte this error ?

      Cannot assign to non-existent property "engineIndexHtml"
      

      The meaning of the message is clear but why? what is missing ?

      A Offline
      A Offline
      ambershark
      wrote on last edited by ambershark
      #2

      @elicat said in qmlRegisterType dont' recogized into qml file:

      qmlRegisterType<engineIndexHtml>("PageIndexHtml", 1, 0, "engineIndexHtml");

      import PageIndexHtml 2.0

      You declared it as a 1.0 version but imported a 2.0 version.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      1
      • elicatE elicat

        Hello,
        Now i'm sudy use webengine (into ubuntu 32bit with QT 5.5)
        i have declare in main.cpp

         qmlRegisterType<engineIndexHtml>("PageIndexHtml", 1, 0, "engineIndexHtml");
        

        thi is a class qith file engineIndexHtml.h

        class engineIndexHtml : public QObject
        {
            Q_OBJECT
            Q_PROPERTY(int answerToLife READ answerToLife NOTIFY answerToLifeChanged)
        public:
            explicit engineIndexHtml(QObject *parent = 0);
            int answerToLife() const;
            Q_INVOKABLE void changeAnswerToLife();
        signals:
            void answerToLifeChanged(int answer);
        private:
            int m_answerToLife;
        
        };
        

        and engineIndexHtml.cpp

        #include "engineindexhtml.h"
        
        engineIndexHtml::engineIndexHtml(QObject *parent)
            : QObject(parent),
              m_answerToLife(42)
        {
        }
        
        int engineIndexHtml::answerToLife() const
        {
            return m_answerToLife;
        }
        void engineIndexHtml::changeAnswerToLife()
        {
            m_answerToLife = (int) (m_answerToLife * 8.5f) % 43;
            emit answerToLifeChanged(m_answerToLife);
        }
        

        After i want use object into QML file

        . . . .
        import PageIndexHtml 2.0
        
        Window {
            engineIndexHtml {
                id: oldBeardedMan
                WebChannel.id: "wiseMan"
            }
        

        Why QmlApplicationEngine don't load component and wirte this error ?

        Cannot assign to non-existent property "engineIndexHtml"
        

        The meaning of the message is clear but why? what is missing ?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @elicat said in qmlRegisterType dont' recogized into qml file:

        Cannot assign to non-existent property "engineIndexHtml"

        beside what @ambershark said, types always must start with a capital letter!

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        elicatE 1 Reply Last reply
        1
        • J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          Additionally to the previous posters,

          you need to register your types before creating the QQmlApplicationEngine object:

          qmlRegisterType<YX>(....);
          
          QQmlApplicationEngine engine;
          engine.load(...);
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          1
          • raven-worxR raven-worx

            @elicat said in qmlRegisterType dont' recogized into qml file:

            Cannot assign to non-existent property "engineIndexHtml"

            beside what @ambershark said, types always must start with a capital letter!

            elicatE Offline
            elicatE Offline
            elicat
            wrote on last edited by elicat
            #5

            @raven-worx I had forgotten the rule, thank you and the row of register it had been put before

             QQmlApplicationEngine engine;
            

            Thanks

            Saluti, Gianfranco Elicat

            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