void OMCSConsole::slot_OMCS() { mMapCanvas = new QgsMapCanvas(this,0); //QSettings settings; //mMapCanvas->freeze( true ); if ( mMapCanvas && mMapCanvas->isDrawing() ) { return; } // possibly save any pending work before opening a new project if ( saveDirty() ) { // Retrieve last used project dir from persistent settings QSettings settings; QString lastUsedDir = settings.value( "/home/bijay", "." ).toString();//UI/lastProjectDir cout<<"lastUsedDir::"<setFileMode( QFileDialog::ExistingFile ); qDebug(""); QString fullPath; //cout<<"inside slot_OMCS"<exec() == QDialog::Accepted ) { fullPath = openFileDialog->selectedFiles().first(); cout<<"full path is "<freeze( true ); // removeAllLayers(); //delete mComposer; //mComposer = new QgsComposer( this ); QgsProject::instance()->setFileName( fullPath ); try { if ( QgsProject::instance()->read() ) { setTitleBarText_( *this ); emit projectRead(); // let plug-ins know that we've read in a new // project so that they can check any project // specific plug-in state // add this to the list of recently used project files saveRecentProjectPath( fullPath, settings ); } } catch ( QgsProjectBadLayerException & e ) { QMessageBox::critical( this, tr( "QGIS Project Read Error" ), tr( "" ) + "\n" + QString::fromLocal8Bit( e.what() ) ); qDebug( QString( "%1 bad layers found" ).arg( e.layers().size() ) ); // attempt to find the new locations for missing layers // XXX vector file hard-coded -- but what if it's raster? findLayers_( mVectorFileFilter, e.layers() ); } catch ( std::exception & e ) { QMessageBox::critical( this, tr( "QGIS Project Read Error" ), tr( "" ) + "\n" + QString::fromLocal8Bit( e.what() ) ); qDebug( "BAD QgsMapLayer::LayerType FOUND" ); } mMapCanvas->freeze( false ); mMapCanvas->refresh(); } //openProject(); }