// CustomCursorTool.cpp #include "CustomCursorTool.h" #include #include #include #include #include #include #include #include #include #include "qgsmapmouseevent.h" #include "qgsmaptoolidentify.h" #include #include #include CustomCursorTool::CustomCursorTool(QgsMapCanvas* canvas) : QgsMapToolIdentify(canvas) { canvas->setCursor(Qt::CrossCursor); } void CustomCursorTool::canvasMoveEvent(QgsMapMouseEvent* e) { if (!canvas()) return; QgsPointXY pointxy= e->pos(); QList result; QList allLayers = mCanvas->layers(); if (allLayers.count() == 0) { return; } QList < QgsMapToolIdentify::IdentifyResult > rasterlayerresult=this->identify(e->x(), e->y(), IdentifyMode::ActiveLayer, allLayers,QgsMapToolIdentify::Type::RasterLayer); QList < QgsMapToolIdentify::IdentifyResult > meshlayerresult=this->identify(e->x(), e->y(), IdentifyMode::ActiveLayer, allLayers, QgsMapToolIdentify::Type::MeshLayer); for (int32_t i = 0; i < rasterlayerresult.count(); i++) { result.append(rasterlayerresult[i]); } for (int32_t i = 0; i < meshlayerresult.count(); i++) { result.append(meshlayerresult[i]); } if (result.count() > 0){ emit identifyResultChange(result); } else { } }