[India-discuss] displaying Vector/Raster layer in Qt using QGIS APIs
Pv Kc
pkoffice232 at gmail.com
Mon Jan 25 02:51:05 PST 2021
Hi ,
I am trying to render a vector and raster layer in Qt using QGIS libraries.
I downloaded all the required files using OSGEO4W installer and followed
some examples on the internet.
But my application is getting crashed .
I am using Qt 5.9 with VS2015 .
I am using a batch file(Creator1_5.9.bat) to launch Qt .
I am including my source code as well as console output.
Any lead will be very helpful.
I am attaching the batch file(creator1_5.9.bat) as a text file .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/india-discuss/attachments/20210125/716b0d6f/attachment.html>
-------------- next part --------------
Starting C:\Users\Puneet Kumar\Desktop\Help Waheguru\mark6\release\mark6.exe...
..\..\..\src\core\qgsapplication.cpp(161) : (QgsApplication::QgsApplication) [0ms] loading of qgis translation failed C:\OSGeo4W64\apps\qgis-ltr-dev/./i18n//qgis_
..\..\..\src\core\qgsapplication.cpp(176) : (QgsApplication::QgsApplication) [0ms] loading of qt translation failed C:/src/osgeo4w/qt5/osgeo4w/qt5/5.11.2/msvc2015_64/translations/qt_
*** QGS Application Instance Created ***
..\..\..\src\core\qgsproviderregistry.cpp(131) : (QgsProviderRegistry::init) [285ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins for provider plugins
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/basicauthmethod.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/coordinatecaptureplugin.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/esritokenauthmethod.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/evis.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [15ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/geometrycheckerplugin.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/georefplugin.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [16ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/gpsimporterplugin.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(161) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/grassplugin7.dll: ...invalid (lib not loadable): Cannot load library C:\OSGeo4W64\apps\qgis-ltr-dev\plugins\grassplugin7.dll: The specified module could not be found.
..\..\..\src\core\qgsproviderregistry.cpp(161) : (QgsProviderRegistry::init) [16ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/grassprovider7.dll: ...invalid (lib not loadable): Cannot load library C:\OSGeo4W64\apps\qgis-ltr-dev\plugins\grassprovider7.dll: The specified module could not be found.
..\..\..\src\core\qgsproviderregistry.cpp(161) : (QgsProviderRegistry::init) [6ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/grassrasterprovider7.dll: ...invalid (lib not loadable): Cannot load library C:\OSGeo4W64\apps\qgis-ltr-dev\plugins\grassrasterprovider7.dll: The specified module could not be found.
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/identcertauthmethod.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/oauth2authmethod.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/offlineeditingplugin.dll: ...invalid (no providerMetadataFactory method)
ERROR 1: Can't load requested DLL: C:\OSGeo4W64\apps\gdal-dev\bin\gdalplugins\ogr_MSSQLSpatial.dll
126: The specified module could not be found.
ERROR 1: Can't load requested DLL: C:\OSGeo4W64\apps\gdal-dev\bin\gdalplugins\ogr_MSSQLSpatial.dll
126: The specified module could not be found.
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [16ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/pkcs12authmethod.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [0ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/pkipathsauthmethod.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(169) : (QgsProviderRegistry::init) [15ms] Checking C:/OSGeo4W64/apps/qgis-ltr-dev/plugins/topolplugin.dll: ...invalid (no providerMetadataFactory method)
..\..\..\src\core\qgsproviderregistry.cpp(190) : (QgsProviderRegistry::init) [0ms] Loaded 20 providers (DB2;WFS;arcgisfeatureserver;arcgismapserver;delimitedtext;gdal;geonode;gpx;mdal;memory;mesh_memory;mssql;ogr;oracle;ows;postgres;spatialite;virtual;wcs;wms)
..\..\..\src\core\qgsapplication.cpp(1645) : (QgsApplication::applyGdalSkippedDrivers) [0ms] Gdal Skipped driver list set to:
..\..\..\src\core\qgsapplication.cpp(1646) : (QgsApplication::applyGdalSkippedDrivers) [0ms]
proj_create_from_database: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(2873) : (createFilters) [47ms] Driver count: 92
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver ESRIC for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver VICAR for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver EEDA for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver DB2ODBC for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver OGR_SDTS for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver Memory for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver OGR_OGDI for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver GPSBabel for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver OGR_PDS for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver WFS for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver OAPIF for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver AeronavFAA for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver Cloudant for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver Elasticsearch for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver Walk for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver Carto for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver AmigoCloud for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver Selafin for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver PLSCENES for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver CSW for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver NGW for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver MapML for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(3266) : (createFilters) [0ms] Unknown driver HTTP for file filters.
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(482) : (QgsOgrProvider::QgsOgrProvider) [16ms] Data source uri is [AFG_adm1.shp]
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(269) : (AnalyzeURI) [0ms] Data source uri is [AFG_adm1.shp]
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(4547) : (QgsOgrProvider::open) [0ms] OGR opened using Driver ESRI Shapefile
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(4594) : (QgsOgrProvider::open) [6ms] Data source is valid
..\..\..\src\core\qgsdatasourceuri.cpp(60) : (QgsDataSourceUri::QgsDataSourceUri) [32ms] = expected after parameter name, skipping text '.\AFG_adm1.qml'
*************valid hai********
addmaplayer
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(1323) : (QgsOgrProvider::extent) [3802ms] Starting get extent
proj_create_from_database: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
..\..\..\src\core\providers\ogr\qgsogrprovider.cpp(1380) : (QgsOgrProvider::extent) [0ms] Finished get extent
proj_create_from_database: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
*****************refresh****************
..\..\..\src\core\qgsmessagelog.cpp(29) : (QgsMessageLog::logMessage) [105ms] 2021-01-25T15:49:15 [2] Cannot create transform between EPSG:4326 and : proj_create_operations: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
..\..\..\src\core\qgscoordinatetransform_p.cpp(253) : (QgsCoordinateTransformPrivate::initialize) [0ms] Coordinate transformation failed to initialize!
The program has unexpectedly finished.
-------------- next part --------------
PATH=C:\OSGeo4W64\apps\qgis-ltr-dev\bin;C:\OSGeo4W64\apps\gdal-dev\pymod3\scripts;C:\OSGeo4W64\apps\Python37;C:\OSGeo4W64\apps\Python37\Scripts;C:\OSGeo4W64\apps\gdal-dev\bin;C:\OSGeo4W64\apps\proj-dev\bin;C:\OSGeo4W64\apps\Qt5\bin;C:\OSGeo4W64\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;%PATH%
set GDAL_DATA=C:\OSGeo4W64\apps\gdal-dev\share\gdal
set GDAL_DRIVER_PATH=C:\OSGeo4W64\apps\gdal-dev\bin\gdalplugins
set GDAL_FILENAME_IS_UTF8=YES
set GEOTIFF_CSV=C:\OSGeo4W64\share\epsg_csv
set JPEGMEM=1000000
set OSGEO4W_ROOT=C:\OSGeo4W64
set PROJ_LIB=C:\OSGeo4W64\apps\proj-dev\share\proj
set PYTHONHOME=C:\OSGeo4W64\apps\Python37
set PYTHONPATH=C:\OSGeo4W64\apps\gdal-dev\pymod3\Lib\site-packages;C:\OSGeo4W64\apps\Python37;C:\OSGeo4W64\apps\Python37\Scripts
set QGIS_PREFIX_PATH=C:\OSGeo4W64\apps\qgis-ltr-dev
set QT_PLUGIN_PATH=C:\OSGeo4W64\apps\qgis-ltr-dev\qtplugins;C:\OSGeo4W64\apps\Qt5\plugins
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set O4W_QT_PREFIX=C:\OSGeo4W64\apps\Qt5
set O4W_QT_BINARIES=C:\OSGeo4W64\apps\Qt5\bin
set O4W_QT_PLUGINS=C:\OSGeo4W64\apps\Qt5\plugins
set O4W_QT_LIBRARIES=C:\OSGeo4W64\apps\Qt5\lib
set O4W_QT_TRANSLATIONS=C:\OSGeo4W64\apps\Qt5\translations
set O4W_QT_HEADERS=C:\OSGeo4W64\apps\Qt5\include
start "Qt Creator" /B C:\Qt\Qt5.9.0\Tools\QtCreator\bin\qtcreator.exe %*
-------------- next part --------------
#include "mainwindow.h"
#include <QApplication>
// QGIS Includes
#include <qgsapplication.h>
#include <QtDebug>
#include <qgsproviderregistry.h>
#include <qgssinglesymbolrenderer.h>
#include <qgsmaplayerregistry.h>
#include <qgsvectorlayer.h>
#include <qgsmapcanvas.h>
#include <qgsmapcanvasmap.h>
#include <qgsmaplayer.h>
#include <qgsproject.h>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QgsApplication app(argc, argv, true);
QgsApplication::setPrefixPath( "C:\\OSGeo4W64\\apps\\qgis", true );
QgsApplication::init();
qDebug() << "*** QGS Application Instance Created *** ";
//QString myPluginsDir = "C:\\OSGeo4W64\\QGIS\\ms-windows\\osgeo4w\\build-qgis-test-x86_64\\output\\plugins";
QString myPluginsDir ="C:\\OSGeo4W64\\apps\\qgis-ltr-dev\\plugins";
QString myLayerPath = "AFG_adm1.shp";
QString myLayerBaseName = "Layer";
QString myProviderName = "ogr";
// Instantiate Provider Registry
QgsProviderRegistry::instance(myPluginsDir);
// create maplayer instances
QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath, myLayerBaseName, myProviderName);
QgsSingleSymbolRenderer *mypRenderer = new QgsSingleSymbolRenderer(reinterpret_cast<QgsSymbol*>(mypLayer->geometryType()));
// QList <QgsMapCanvasLayer> myLayerSet;
mypLayer->setRenderer(mypRenderer);
if(mypLayer->isValid())
qDebug()<<"*************valid hai********";
else
qDebug()<<"************Not valid******";
QList <QgsMapLayer*> myLayerSet;
// QgsMapLayerRegistry::instance()->addMapLayer(mypLayer, true);
QgsProject::instance()->addMapLayer(mypLayer,true);
qDebug()<<"addmaplayer";
// Add the Layer to the Layer Set
//myLayerSet.append(QgsMapLayer(mypLayer, true));
myLayerSet.append((QgsMapLayer*)mypLayer);
// Create the Map Canvas
QgsMapCanvas * mypMapCanvas = new QgsMapCanvas();
mypMapCanvas->setExtent(mypLayer->extent());
mypMapCanvas->enableAntiAliasing(true);
mypMapCanvas->setCanvasColor(QColor(255, 255, 255));
mypMapCanvas->freeze(false);
// Set the Map Canvas Layer Set
mypMapCanvas->setLayers(myLayerSet);
mypMapCanvas->setVisible(true);
mypMapCanvas->refresh();
qDebug()<<"*****************refresh****************";
int exitCode= app.exec();
QgsApplication::exitQgis();
return exitCode;
}
-------------- next part --------------
#-------------------------------------------------
#
# Project created by QtCreator 2021-01-04T18:38:34
#
#-------------------------------------------------
QT += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = mark6
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH += "C:/OSGeo4W64/include"
INCLUDEPATH += "C:/OSGeo4W64/apps/qgis-ltr-dev/include"
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
win32: LIBS += -L$$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib/ -lqgis_core
INCLUDEPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEPENDPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
win32: LIBS += -L$$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib/ -lqgis_3d
INCLUDEPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEPENDPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
win32: LIBS += -L$$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib/ -lqgis_analysis
INCLUDEPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEPENDPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
win32: LIBS += -L$$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib/ -lqgis_app
INCLUDEPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEPENDPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
win32: LIBS += -L$$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib/ -lqgis_gui
INCLUDEPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEPENDPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
win32: LIBS += -L$$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib/ -lqgis_native
INCLUDEPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEPENDPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
win32: LIBS += -L$$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib/ -lqgis_server
INCLUDEPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEPENDPATH += $$PWD/../../../../../OSGeo4W64/apps/qgis-ltr-dev/lib
DEFINES += GUI_EXPORT= CORE_EXPORT=
More information about the India-discuss
mailing list