QGIS环境搭建好后,我跟着写了一个基础的项目:使用qgis画布加载矢量数据
首先准备好一个.shp文件,也就是我们的矢量图。
创建一个基类为QMainWindow的项目,在.pro文件里增添xml模块,并引入库文件的目录(自定义)
QT += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += _USE_MATH_DEFINES
LIBS += -L"D:\OSGeo4w\apps\qgis-ltr\lib" -lqgis_core -lqgis_gui -lqgis_3d -lqgis_analysis -lqgis_app -lqgis_native -lqgis_server
LIBS += -L"D:\OSGeo4w\apps\Qt5\lib" -lQt53DCore -lQt53DRender -lQt5Core -lQt5Gui
INCLUDEPATH += "D:\OSGeo4w\apps\qgis-ltr\include"
INCLUDEPATH += "D:\OSGeo4w\include"
INCLUDEPATH += "D:\OSGeo4w\apps\Qt5\include\Qt3DCore"
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
# Default rules

本文介绍了如何在QGIS环境中创建一个基于QMainWindow的应用,通过.shp文件加载矢量数据,包括设置数据驱动插件、配置文件和实现加载shapefile的步骤。
最低0.47元/天 解锁文章
1289





