put marker on a vector layer / map
Unsolved
Qt Creator and other tools
-
I am designing a GUI using Qt and QGIS and showing maps (shapefiles - Vector layers) on the GUI. I want to put a marker on the vector layers when I click somewhere on the map. I could get coordinates when I click on the vector layer. I am using QLabel class for the marker. I am moving the marker according to coordinates. The logic and related part of the code is as following:
mpClickPoint = new QgsMapToolEmitPoint(mpMapCanvas); connect(mpClickPoint, SIGNAL(canvasClicked(QgsPointXY,Qt::MouseButton)), this, SLOT(selectCoord(QgsPointXY))); void MainWindow::selectCoord(QgsPointXY point) { QLabel *marker = new QLabel(mpMapCanvas); marker->setPixmap(QPixmap(":/mapMarker.png")); marker->move(point.x(), point.y()); marker->show(); }
The problem is, wherever I click on the map, the markers are put somewhere else and they are put so close to each other. As you can see in the image below, I clicked 10 times on different places and markers have been put in the area on the top left of the map. How can I put markers correctly? Or should I follow another way?
The Output is like follows: