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. Error importing extended QML type
Forum Updated to NodeBB v4.3 + New Features

Error importing extended QML type

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 316 Views
  • 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.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by Tom asso
    #1

    Trying to extend Surface3DSeries, adding a property “topoFile” which has value of type QString. But the QML editor seems unable to import the extended type. I define the C++ class which will extend Surface3DSeries, with a Q_PROPERTY “topoFile”:

    class TopographicSeries : public QObject
    {
     Q_OBJECT
     Q_PROPERTY(QString topoFile READ getTopoFile WRITE setTopoFile )
    

    I register the extended type in main.cpp:

    int main(int argc, char *argv[])
    {
     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
     QGuiApplication app(argc, argv);
    
     qmlRegisterExtendedType<QSurface3DSeries, TopographicSeries>("Test", 1, 0, "Surface3DSeries");
    

    But the QML view displays "QML module not found" when I try to import the extended type in main.qml:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtDataVisualization 1.0
    import Test 1.0   * QML module not found (Test)
    

    All of my project files are in the same directory, and my .pro file includes this:

    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH = $$PWD
    

    Does anyone know what I am doing wrong?

    Thanks
    Tom

    Tom assoT 1 Reply Last reply
    0
    • Tom assoT Tom asso

      Trying to extend Surface3DSeries, adding a property “topoFile” which has value of type QString. But the QML editor seems unable to import the extended type. I define the C++ class which will extend Surface3DSeries, with a Q_PROPERTY “topoFile”:

      class TopographicSeries : public QObject
      {
       Q_OBJECT
       Q_PROPERTY(QString topoFile READ getTopoFile WRITE setTopoFile )
      

      I register the extended type in main.cpp:

      int main(int argc, char *argv[])
      {
       QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
       QGuiApplication app(argc, argv);
      
       qmlRegisterExtendedType<QSurface3DSeries, TopographicSeries>("Test", 1, 0, "Surface3DSeries");
      

      But the QML view displays "QML module not found" when I try to import the extended type in main.qml:

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtDataVisualization 1.0
      import Test 1.0   * QML module not found (Test)
      

      All of my project files are in the same directory, and my .pro file includes this:

      # Additional import path used to resolve QML modules in Qt Creator's code model
      QML_IMPORT_PATH = $$PWD
      

      Does anyone know what I am doing wrong?

      Thanks
      Tom

      Tom assoT Offline
      Tom assoT Offline
      Tom asso
      wrote on last edited by
      #2

      Another mysterious problem. As a test I removed reference to the Surface3DSeries "topoFile" property from main.qml, and instead get topography from an ItemModelSurfaceDataProxy defined in the qml. However now when I run the app I get this error in the output:

      QQmlApplicationEngine failed to load component
      qrc:/main.qml:19 Invalid property assignment: "seriesList" is a read-only property
      

      seriesList is a property of Surface3D. Why in the world would something be trying to write that property if the qml makes no reference to the extended QSurface3DSeries "topoFile" property? If I remove the call to qmlRegisterExtendedType() in main.cpp, the app executes without error.

      Here is the qml file:

      import QtQuick 2.0
      import QtQuick.Window 2.12
      import QtDataVisualization 1.2
      
      Window {
          visible: true
          id: mainWindow
          width: 640
          height: 480
          title: qsTr("TopoSeries test")
      
          Item {
              width: 640
              height: 480
      
              Surface3D {
                  width: parent.width
                  height: parent.height
                  Surface3DSeries {
                      ItemModelSurfaceDataProxy {
                          itemModel: dataModel
                          // Mapping model roles to surface series rows, columns, and values.
                          rowRole: "longitude"
                          columnRole: "latitude"
                          yPosRole: "elevation"
                      }
                  }
              }
              ListModel {
                  id: dataModel
                  ListElement{ longitude: "20"; latitude: "10"; elevation: "1000"; }
                  ListElement{ longitude: "21"; latitude: "10"; elevation: "1200"; }
                  ListElement{ longitude: "22"; latitude: "10"; elevation: "900"; }
                  ListElement{ longitude: "23"; latitude: "10"; elevation: "1100"; }
                  ListElement{ longitude: "20"; latitude: "11"; elevation: "1000"; }
                  ListElement{ longitude: "21"; latitude: "11"; elevation: "1300"; }
                  ListElement{ longitude: "22"; latitude: "11"; elevation: "1250"; }
                  ListElement{ longitude: "23"; latitude: "11"; elevation: "1200"; }
                  ListElement{ longitude: "20"; latitude: "12"; elevation: "1100"; }
                  ListElement{ longitude: "21"; latitude: "12"; elevation: "1000"; }
                  ListElement{ longitude: "22"; latitude: "12"; elevation: "950"; }
                  ListElement{ longitude: "23"; latitude: "12"; elevation: "900"; }
                  ListElement{ longitude: "20"; latitude: "13"; elevation: "850"; }
                  ListElement{ longitude: "21"; latitude: "13"; elevation: "800"; }
                  ListElement{ longitude: "22"; latitude: "13"; elevation: "750"; }
                  ListElement{ longitude: "23"; latitude: "13"; elevation: "700"; }
              }
          }
      }
      
      
      
      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