QMetaProperty::read: Unable to handle unregistered datatype 'QObjectList'

119
12 декабря 2019, 23:10

Ошибка: QMetaProperty::read: Unable to handle unregistered datatype 'QObjectList' for property 'ViewshedGeoElement_QMLTYPE_43::PointLogLag'

Я в main зарегистрировал :

int main(int argc, char *argv[])
{
    qRegisterMetaType<QObjectList*>("QObjectLists*");
    ...
}

Файл класса ViewshedGeoElement (ViewshedGeoElement.h)

    #include <QObjectList>
    using namespace Esri::ArcGISRuntime;
    class ViewshedGeoElement : public QQuickItem
    {
        Q_OBJECT
        Q_PROPERTY(QObjectList PointLogLag READ PointLogLag NOTIFY PointLogLagChanged)
       ...
       public:
         static void init();
       private:
         QObjectList m_PointLogLag;
         QObjectList PointLogLag() const;    
     };

Файл класса ViewshedGeoElement (ViewshedGeoElement.cpp)

...
    void ViewshedGeoElement::init()
    {
       // Register classes for QML
       qmlRegisterType<SceneQuickView>("Esri.Samples", 1, 0, "SceneView");
       qmlRegisterType<ViewshedGeoElement>("Esri.Samples", 1, 0, "ViewshedGeoElementSample");
    }
    void ViewshedGeoElement::componentComplete()
    {
    ...
        connect(m_sceneView, &SceneQuickView::mouseClicked, this, [this](QMouseEvent& mouseEvent)
        {
          Point clickedPoint = m_sceneView->screenToBaseSurface(mouseEvent.x(), mouseEvent.y());
          m_PointLogLag.append(new Coordinates(clickedPoint.x(),clickedPoint.y()));
          emit PointLogLagChanged();
    //      points.append(clickedPoint);
        });
    }
    QObjectList ViewshedGeoElement::PointLogLag() const
    {
       return m_PointLogLag;
    }

файл класса Coordinates coordinates.h:

#ifndef COORDINATES_H
#define COORDINATES_H
#include <QObject>
#include <QVariant>
class Coordinates : public QObject
{
    Q_OBJECT
    Q_PROPERTY(double latitude READ latitude WRITE setLatitude NOTIFY latitudeChanged)
    Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged)
public:
    Coordinates(QObject *parent = nullptr);
    Coordinates(const Coordinates &other);
    Coordinates(double latitude,double longitude,QObject *parent = nullptr);
    void setLatitude(const double &latitude);
    void setLongitude(const double &longitude);
    double latitude() const;
    double longitude() const;
signals:
    void latitudeChanged();
    void longitudeChanged();
private:
    double m_latitude;
    double m_longitude;
};
Q_DECLARE_METATYPE(Coordinates*)
#endif // COORDINATES_H

файл класса Coordinates coordinates.cpp :

#include "coordinates.h"
Coordinates::Coordinates(QObject *parent)
    :QObject{parent}
    ,m_latitude {0.0}
    ,m_longitude {0.0}
{
}
Coordinates::Coordinates(const Coordinates &other)
  :QObject{other.parent()}
  ,m_latitude {other.m_latitude}
  ,m_longitude {other.m_longitude}
{
}
Coordinates::Coordinates(double latitude,double longitude,QObject *parent)
    :QObject{parent}
    ,m_latitude {latitude}
    ,m_longitude {longitude}
{
}
void Coordinates::setLatitude(const double &latitude)
{
    if (m_latitude !=latitude)
    {
        m_latitude = latitude;
        emit latitudeChanged();
    }
}
void Coordinates::setLongitude(const double &longitude)
{
    if (m_longitude != longitude)
    {
        m_longitude = longitude;
        emit longitudeChanged();
    }
}
double Coordinates::latitude() const
{
    return m_latitude;
}
double Coordinates::longitude() const
{
    return m_longitude;
}
READ ALSO
Создание объектов класса с++

Создание объектов класса с++

Предположим, существует некоторый класс foo с конструктором по умолчаниюВ main() происходит его создание

126
Не устанавливается Microsoft Visial Studio 2017

Не устанавливается Microsoft Visial Studio 2017

Пытаюсь установить MSVS 2017На этапе установки SDK установщик начинает требовать какие-то пакеты

113
Как программно создать GridLayout

Как программно создать GridLayout

Нужно создать таблицу типа такой:

134