2

This is my code whenever i try to load .tif image it shows layer is not valid,QgsRasterLayer always return invalid layer (I am using linux 12.04).

QString myFileName = QFileDialog::getOpenFileName(this,tr("OpenFile"),"/home/ravi",tr("*.tiff"));
std::cout<<"File Name:"<<myFileName.toStdString();
QFileInfo myRasterFileInfo(myFileName);
QgsRasterLayer * mypLayer = new QgsRasterLayer(myRasterFileInfo.filePath(),
myRasterFileInfo.completeBaseName());
if (mypLayer->isValid())
{
   qDebug("Layer is valid");
}
else
{
   qDebug("Layer is NOT valid");
   return;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.