Geographic Information Systems Asked by ainardi on January 28, 2021
I am working under C++ with the QGIS API 2.8
In order to make different operation on a canvas like personalized rotation or selecting a region for zooming, I had to catch different signal like rightclick, leftclick, clicked or dblclick.
I saw in the API online the class QgsMapToolEmitPoint
, Does anyone already used it ?
I found the solution A lot of post on stackexchange showme the way to do that
Here a sample extract of the code in c++ :
//Declaration
CMyQgsMapCanvas * mpMapCanvas;
QgsMapToolEmitPoint * mpClickPoint;
mpMapCanvas = new CMyQgsMapCanvas( this, NULL);
mpMapCanvas->create();
mpMapCanvas->setProjection();
mpClickPoint = new QgsMapToolEmitPoint(mpMapCanvas);
mpMapCanvas->setMapTool(mpClickPoint);
connect(mpClickPoint ,SIGNAL(canvasClicked(QgsPoint,Qt::MouseButton)),this, SLOT(calcPoint(QgsPoint,Qt::MouseButton)));
// the slot
void MainWindow::calcPoint(QgsPoint pPoint,Qt::MouseButton pMouseBtn)
{
qDebug() << "Mouse Click";
}
Now each you click on the canvas the slot was called. I think that mpClickPoint can be a QgsMapTool cause of inherit of classes
Correct answer by ainardi on January 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP