Affichage de points 2 - C++/QML
Bonjour à tous,
je reviens vers vous pour mon "problème" d'affichage de points.
Pour le moment, je ne pars plus de ma BDD ; je travaille en "statique".
Le fait est je pense être sur la bonne direction. Cependant j'ai encore quelques difficultés.
Je définis une classe point avec les propriétés adéquates.
Cependant, au moment de passer sur le QML, je définis mon objet Point.
Mais je n'arrive pas d'une part à lui dire que c'est un point géographique ; et d'autre part lui associé l'image appropriée.
voici mon code :
le .h
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#ifndef POINTS_H
#define POINTS_H
#include <QObject>
#include <QFile>
#include <QPointF>
#include <QList>
#include <QGeoPositionInfo>
#include <QGeoLocation>
#include <QGeoCoordinate>
#include <QPixmap>
class Points : public QObject
{
Q_OBJECT
Q_PROPERTY(double llatitude
READ getLatitude WRITE setLatitude
NOTIFY datachanged)
Q_PROPERTY(double llongitude
READ getLongitude WRITE setLongitude
NOTIFY datachanged)
Q_PROPERTY(int idd
READ getId WRITE setId
NOTIFY datachanged)
Q_PROPERTY(QGeoCoordinate coord READ getPosition)
//Q_PROPERTY(QPixmap pixmap READ getPixmap )
public:
explicit Points(QObject *parent = nullptr);
~Points();
Points(const Points &);
//Q_INVOKABLE QGeoCoordinate getPosition(double lat, double lon);
signals:
Q_INVOKABLE void datachanged();
public slots:
/*Return the Value*/
Q_INVOKABLE double getLatitude();
Q_INVOKABLE double getLongitude();
Q_INVOKABLE int getId();
Q_INVOKABLE QGeoCoordinate getPosition();
//Q_INVOKABLE QPixmap getPixmap();
/*Affect the value*/
Q_INVOKABLE void setLatitude(const double &Lat);
Q_INVOKABLE void setLongitude(const double &Long);
Q_INVOKABLE void setId(const int &id_point);
private:
double llatitude;
double llongitude;
int idd;
//QPixmap pixmap = QPixmap("marker.jpg");
QGeoCoordinate coord = QGeoCoordinate(llatitude,llongitude);
};
#endif // POINTS_H
[/QT]
le .cpp
[QT]
include "points.h"
Points:: Points(QObject *parent) : QObject(parent)
{
}
Points:: Points(const Points &P)
{
llatitude = P.llatitude;
llongitude = P.llongitude;
idd = P.idd;
}
Points::~Points()
{
}
int Points::getId()
{
return idd;
}
double Points::getLatitude()
{
return llatitude;
}
double Points::getLongitude()
{
return llongitude;
}
/*QPixmap *Points::getPixmap()
{
return pixmap;
}*/
void Points::setId(const int &id_point)
{
idd = id_point;
}
void Points::setLatitude(const double &Lat)
{
llatitude = Lat;
coord.setLatitude(llatitude);
}
void Points::setLongitude(const double &Long)
{
llongitude = Long;
coord.setLongitude(llongitude);
}
QGeoCoordinate Points::getPosition()
{
return coord;
} |
Merci à tous de m'avoir lu et de m'apporter un élément de réponse.
Cordialement,
KM