#include #include #include #include #include #include #include class MyModel : public QAbstractListModel { public: virtual int rowCount(const QModelIndex& index) const override { if(!index.isValid()) return _count; else return 0; } QHash roleNames() const { QHash roles; roles[Qt::UserRole] = "PathData"; return roles; } virtual QVariant data(const QModelIndex& index, int role) const override { if(role == Qt::UserRole) return QVariant::fromValue(QGeoPath({QGeoCoordinate(0,0), QGeoCoordinate(1,1)})); else return QVariant(); } void changeItemCount(int count) { beginResetModel(); _count = count; endResetModel(); } int _count = 25000; }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); MyModel myModel; QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("myModel", &myModel); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QTimer::singleShot(10000, [&] { QObject* map = engine.rootObjects().first()->findChild("myMap"); QMetaObject::invokeMethod(map, "clearMapItems"); }); return app.exec(); }