i have a college project that searches content in map. I did all instruction written in this site:http://kartoza.com/how-to-build-and-debug-qgis-with-qtcreator
then built my sample project.this is my .pro file:
QT+= core gui xmlgreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = testTEMPLATE =libSOURCES += main.cpp\ mainwindow.cppHEADERS += mainwindow.hFORMS += mainwindow.uiINCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/coreINCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/core/symbology-ngINCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/guiDEFINES += GUI_EXPORT= CORE_EXPORT=and this here is my source file:
QgsApplication app(argc, argv,true); QString myPluginsDir = "/home/timlinux/apps/lib/qgis"; QString myLayerPath = "/home/timlinux/gisdata/brazil/BR_Cidades/"; QString myLayerBaseName = "Brasil_Cap"; QString myProviderName = "ogr"; // Instantiate Provider Registry QgsProviderRegistry::instance(myPluginsDir); // create a maplayer instance QgsVectorLayer * mypLayer =new QgsVectorLayer(myLayerPath, myLayerBaseName, myProviderName); QgsSymbolV2 * x= QgsSymbolV2::defaultSymbol(mypLayer->geometryType()); QgsSingleSymbolRendererV2 *mypRenderer = new QgsSingleSymbolRendererV2(x); QList myLayerSet; mypLayer->setRendererV2(mypRenderer); if (mypLayer->isValid()) { qDebug("Layer is valid"); } else { qDebug("Layer is NOT valid"); } // Add the Vector Layer to the Layer Registry QgsMapLayerRegistry::instance()->addMapLayer(mypLayer, TRUE); // Add the Layer to the Layer Set myLayerSet.append(QgsMapCanvasLayer(mypLayer, TRUE));// Create the Map CanvasQgsMapCanvas * mypMapCanvas = new QgsMapCanvas(0, 0);mypMapCanvas->setExtent(mypLayer->extent());mypMapCanvas->enableAntiAliasing(true);mypMapCanvas->setCanvasColor(QColor(255, 255, 255));mypMapCanvas->freeze(false);// Set the Map Canvas Layer SetmypMapCanvas->setLayerSet(myLayerSet);mypMapCanvas->setVisible(true);mypMapCanvas->refresh();// Start the Application Event Loopreturn app.exec();it built successfully!I solved all the built issue,but I dont know how to run it and set the run environment run path?thank you
أكثر...
then built my sample project.this is my .pro file:
QT+= core gui xmlgreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = testTEMPLATE =libSOURCES += main.cpp\ mainwindow.cppHEADERS += mainwindow.hFORMS += mainwindow.uiINCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/coreINCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/core/symbology-ngINCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/guiDEFINES += GUI_EXPORT= CORE_EXPORT=and this here is my source file:
QgsApplication app(argc, argv,true); QString myPluginsDir = "/home/timlinux/apps/lib/qgis"; QString myLayerPath = "/home/timlinux/gisdata/brazil/BR_Cidades/"; QString myLayerBaseName = "Brasil_Cap"; QString myProviderName = "ogr"; // Instantiate Provider Registry QgsProviderRegistry::instance(myPluginsDir); // create a maplayer instance QgsVectorLayer * mypLayer =new QgsVectorLayer(myLayerPath, myLayerBaseName, myProviderName); QgsSymbolV2 * x= QgsSymbolV2::defaultSymbol(mypLayer->geometryType()); QgsSingleSymbolRendererV2 *mypRenderer = new QgsSingleSymbolRendererV2(x); QList myLayerSet; mypLayer->setRendererV2(mypRenderer); if (mypLayer->isValid()) { qDebug("Layer is valid"); } else { qDebug("Layer is NOT valid"); } // Add the Vector Layer to the Layer Registry QgsMapLayerRegistry::instance()->addMapLayer(mypLayer, TRUE); // Add the Layer to the Layer Set myLayerSet.append(QgsMapCanvasLayer(mypLayer, TRUE));// Create the Map CanvasQgsMapCanvas * mypMapCanvas = new QgsMapCanvas(0, 0);mypMapCanvas->setExtent(mypLayer->extent());mypMapCanvas->enableAntiAliasing(true);mypMapCanvas->setCanvasColor(QColor(255, 255, 255));mypMapCanvas->freeze(false);// Set the Map Canvas Layer SetmypMapCanvas->setLayerSet(myLayerSet);mypMapCanvas->setVisible(true);mypMapCanvas->refresh();// Start the Application Event Loopreturn app.exec();it built successfully!I solved all the built issue,but I dont know how to run it and set the run environment run path?thank you
أكثر...