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. TypeError: Property "..."of object "..."(0x1431f8e9420) is not a function. Couldn't find anything online which matched my case, any ideas?
Forum Updated to NodeBB v4.3 + New Features

TypeError: Property "..."of object "..."(0x1431f8e9420) is not a function. Couldn't find anything online which matched my case, any ideas?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.5k 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.
  • C Offline
    C Offline
    CaptainJuice
    wrote on last edited by CaptainJuice
    #1

    main.cpp

    #include "OntarioMaps.h"
    #include "ArcGISRuntimeEnvironment.h"
    #include "MapQuickView.h"
    #include <QDir>
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    //------------------------------------------------------------------------------
    
    using namespace Esri::ArcGISRuntime;
    
    int main(int argc, char *argv[])
    {
        QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QGuiApplication app(argc, argv);
    
        // Register the map view for QML
        qmlRegisterType<MapQuickView>("Esri.OntarioMaps", 1, 0, "MapView");
    
        qmlRegisterUncreatableType<QAbstractListModel>("Esri.OntarioMaps", 1, 0, "AbstractListModel", "AbstractListModel is uncreateable");
    
        // Register the OntarioMaps (QQuickItem) for QML
        qmlRegisterType<OntarioMaps>("Esri.OntarioMaps", 1, 0, "OntarioMaps");
    
        // Initialize application view
        QQmlApplicationEngine engine;
    
        // Add the import Path
        engine.addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
    
    #ifdef ARCGIS_TOOLKIT_IMPORT_PATH_2
        engine.addImportPath(ARCGIS_TOOLKIT_IMPORT_PATH_2);
    #endif
    
        // Set the source
        engine.load(QUrl("qrc:/qml/main.qml"));
    
        return app.exec();
    }
    
    

    OntarioMaps.h

    ...
    
    class OntarioMaps : public QQuickItem
    {
        Q_OBJECT
    
        Q_PROPERTY(Esri::ArcGISRuntime::MapQuickView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged)
        Q_PROPERTY(QAbstractListModel* suggestions READ suggestions NOTIFY suggestionsChanged)
    
    public:
        explicit OntarioMaps(QQuickItem* parent = nullptr);
        ~OntarioMaps() override;
        void componentComplete() override;
        Q_INVOKABLE void geoCode(const QString& query);
        Q_INVOKABLE void clearGraphics();
        Q_INVOKABLE void setSuggestions(const QString& text);
    
    signals:
        void mapViewChanged();
        void suggestionsChanged();
        void hideSuggestionView();
    ...
    };
    

    OntarioMaps.cpp

    ...
    void OntarioMaps::geoCode(const QString& query)
    {
      SuggestParameters suggestParams;
      QStringList categories;
      categories << "Address" << "POI" << "Populated Place";
      suggestParams.setCategories(categories);
      suggestParams.setMaxResults(5);
      m_locatorTask->suggestions()->setSuggestParameters(suggestParams);
      m_locatorTask->geocodeWithParameters(query, m_geocodeParams);
    }
    ...
    

    qml

    ...
      Column {
                id: column
                width: 200
                height: 400
    
                TextField{
                    id: textField
                    width: 285
                    height: 34
                    placeholderText: "Type in an address"
                    font.pixelSize: 12
                    onTextChanged: {
                        if (text.length > 0 && suggestView)
                        {
                            suggestView.visible = true;
                        }
                        model.setSuggestions(text);
                    }
                }
    
                ListView {
                    id: suggestView
                    width: textField.width
                    height: 195
                    model: model.suggestions
    
                    visible: false
                    clip: true
                    delegate: Component {
                        Rectangle {
                            id: rect
                            width: textField.width
                            height: 34
                            color: "#f7f8fa"
    
                            Text {
                                anchors {
                                    verticalCenter: parent.verticalCenter
                                    leftMargin: 5
                                    rightMargin: 5
                                }
    
                                font {
                                    weight: Font.Black
                                    pixelSize: 16
                                }
    
                                width: textField.width
                                text: label
                                elide: Text.ElideRight
                                leftPadding: 5
                                color: "black"
                            }
     MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    textField.text = label;
                                    suggestView.visible = false;
                                    model.geoCode(label);
                                    Qt.inputMethod.hide();
                                }
                            }
                        }
                    }
    
    
                }
            }
    
    
    
            OntarioMaps {
                id: model
                mapView: view
    
            }
    
    The exact error I get is : 
    qrc:/qml/OntarioMapsForm.qml:112: TypeError: Property 'geoCode' of object QQmlDMAbstractItemModelData(0x1b06e4c0e00) is not a function
    

    I tried my best to only include important parts so "..." is where other code would go. I have geoCode() as invokable so I'm not sure where the issue lies. Thanks for your help! Also the geoCode() call is at the end of QML and model.setSuggestions(text) works.

    B 1 Reply Last reply
    0
    • C CaptainJuice

      main.cpp

      #include "OntarioMaps.h"
      #include "ArcGISRuntimeEnvironment.h"
      #include "MapQuickView.h"
      #include <QDir>
      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      //------------------------------------------------------------------------------
      
      using namespace Esri::ArcGISRuntime;
      
      int main(int argc, char *argv[])
      {
          QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
          QGuiApplication app(argc, argv);
      
          // Register the map view for QML
          qmlRegisterType<MapQuickView>("Esri.OntarioMaps", 1, 0, "MapView");
      
          qmlRegisterUncreatableType<QAbstractListModel>("Esri.OntarioMaps", 1, 0, "AbstractListModel", "AbstractListModel is uncreateable");
      
          // Register the OntarioMaps (QQuickItem) for QML
          qmlRegisterType<OntarioMaps>("Esri.OntarioMaps", 1, 0, "OntarioMaps");
      
          // Initialize application view
          QQmlApplicationEngine engine;
      
          // Add the import Path
          engine.addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
      
      #ifdef ARCGIS_TOOLKIT_IMPORT_PATH_2
          engine.addImportPath(ARCGIS_TOOLKIT_IMPORT_PATH_2);
      #endif
      
          // Set the source
          engine.load(QUrl("qrc:/qml/main.qml"));
      
          return app.exec();
      }
      
      

      OntarioMaps.h

      ...
      
      class OntarioMaps : public QQuickItem
      {
          Q_OBJECT
      
          Q_PROPERTY(Esri::ArcGISRuntime::MapQuickView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged)
          Q_PROPERTY(QAbstractListModel* suggestions READ suggestions NOTIFY suggestionsChanged)
      
      public:
          explicit OntarioMaps(QQuickItem* parent = nullptr);
          ~OntarioMaps() override;
          void componentComplete() override;
          Q_INVOKABLE void geoCode(const QString& query);
          Q_INVOKABLE void clearGraphics();
          Q_INVOKABLE void setSuggestions(const QString& text);
      
      signals:
          void mapViewChanged();
          void suggestionsChanged();
          void hideSuggestionView();
      ...
      };
      

      OntarioMaps.cpp

      ...
      void OntarioMaps::geoCode(const QString& query)
      {
        SuggestParameters suggestParams;
        QStringList categories;
        categories << "Address" << "POI" << "Populated Place";
        suggestParams.setCategories(categories);
        suggestParams.setMaxResults(5);
        m_locatorTask->suggestions()->setSuggestParameters(suggestParams);
        m_locatorTask->geocodeWithParameters(query, m_geocodeParams);
      }
      ...
      

      qml

      ...
        Column {
                  id: column
                  width: 200
                  height: 400
      
                  TextField{
                      id: textField
                      width: 285
                      height: 34
                      placeholderText: "Type in an address"
                      font.pixelSize: 12
                      onTextChanged: {
                          if (text.length > 0 && suggestView)
                          {
                              suggestView.visible = true;
                          }
                          model.setSuggestions(text);
                      }
                  }
      
                  ListView {
                      id: suggestView
                      width: textField.width
                      height: 195
                      model: model.suggestions
      
                      visible: false
                      clip: true
                      delegate: Component {
                          Rectangle {
                              id: rect
                              width: textField.width
                              height: 34
                              color: "#f7f8fa"
      
                              Text {
                                  anchors {
                                      verticalCenter: parent.verticalCenter
                                      leftMargin: 5
                                      rightMargin: 5
                                  }
      
                                  font {
                                      weight: Font.Black
                                      pixelSize: 16
                                  }
      
                                  width: textField.width
                                  text: label
                                  elide: Text.ElideRight
                                  leftPadding: 5
                                  color: "black"
                              }
       MouseArea {
                                  anchors.fill: parent
                                  onClicked: {
                                      textField.text = label;
                                      suggestView.visible = false;
                                      model.geoCode(label);
                                      Qt.inputMethod.hide();
                                  }
                              }
                          }
                      }
      
      
                  }
              }
      
      
      
              OntarioMaps {
                  id: model
                  mapView: view
      
              }
      
      The exact error I get is : 
      qrc:/qml/OntarioMapsForm.qml:112: TypeError: Property 'geoCode' of object QQmlDMAbstractItemModelData(0x1b06e4c0e00) is not a function
      

      I tried my best to only include important parts so "..." is where other code would go. I have geoCode() as invokable so I'm not sure where the issue lies. Thanks for your help! Also the geoCode() call is at the end of QML and model.setSuggestions(text) works.

      B Offline
      B Offline
      Bob64
      wrote on last edited by Bob64
      #2

      @CaptainJuice you have instantiated your OntarioMaps with the name model. Try renaming it & obviously update anywhere you reference it. I think when you try to access it in your delegate it is being hidden by the model property of the delegate.

      C 1 Reply Last reply
      1
      • B Bob64

        @CaptainJuice you have instantiated your OntarioMaps with the name model. Try renaming it & obviously update anywhere you reference it. I think when you try to access it in your delegate it is being hidden by the model property of the delegate.

        C Offline
        C Offline
        CaptainJuice
        wrote on last edited by
        #3

        @Bob64 Thankyou! It works now!

        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