I have this code for create and open raster map:
if(QFile::exists(rasterFileName))
{
QFileInfo myRasterFileInfo(rasterFileName);
m_pRasterLayer = QSharedPointer<QgsRasterLayer>(
new QgsRasterLayer(myRasterFileInfo.filePath(),
myRasterFileInfo.completeBaseName()));
if (m_pRasterLayer->isValid())
{
QgsMapLayerRegistry::instance()->addMapLayer(
m_pRasterLayer.data(), true);
QList<QgsMapCanvasLayer> layerList;
layerList.append(QgsMapCanvasLayer(m_pRasterLayer.data(), true));
m_pMapCanvas->setLayerSet(layerList);
/* ... */
}
}
How can I make (write code for) rectangle selection by mouse on my map?