# QtMapWidget **Repository Path**: y4u/qt-map-widget ## Basic Information - **Project Name**: QtMapWidget - **Description**: QtLocation 地图功能。使用 QQuickWidget 加载 QML。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-10-29 - **Last Updated**: 2025-12-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: 个人 ## README # 地图控件 参考 qgroundcontrol-Stable_V4.4 # 如何在项目中使用 参考这个 MapDemo 的代码: Example/main.cpp ```cpp #include "MainWindow.h" #include "../QtMapWidget/QtMapWidget.h" #include #include Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryCustom); int main(int argc, char *argv[]) { QApplication a(argc, argv); QtMapWidget::initQtMapWidget(); MainWindow w; w.show(); return a.exec(); } ``` Example/MainWindow.cpp ```cpp #include "MainWindow.h" #include "ui_MainWindow.h" #include "../QtMapWidget/QtMapWidget.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle("MapDemo"); ui->quickWidget->setSource(QtMapWidget::mapSource()); } MainWindow::~MainWindow() { delete ui; } ``` 运行 MapDemo: ![MapDemo.jpg](https://s2.loli.net/2025/11/28/Vus91v3LtPiFS8n.jpg)