C++과 QML 간의 인터페이스 코드 Qt Positioning
개요
Qt Positioning C++과 QML 코드 간의 위치 데이터 교환을 간소화하기 위해 두 가지 방법을 활용합니다.
직접 매핑
Qt Positioning 이를 통해 QML에서 C++로, 또는 그 반대로 다음과 같은 값 유형을 전달할 수 있습니다:
| C++ 클래스 | QML 값 유형 |
|---|---|
| QGeoCircle | geoCircle |
| QGeoCoordinate | geoCoordinate |
| QGeoPath | geoPath |
| QGeoPolygon | geoPolygon |
| QGeoRectangle | geoRectangle |
| QGeoSatelliteInfo | geoSatelliteInfo |
| QGeoShape | geoShape |
QVariant 기반 통합
이 섹션에서는 QGeoAddress 및 QGeoLocation 를 통합하는 방법에 대한 정보를 제공합니다.
주소 - QGeoAddress
Address.address 속성은 C++과 QML 코드 간의 인터페이스를 제공하는 데 사용됩니다. 먼저 C++에서 Address 객체에 대한 포인터를 확보한 다음, property() 및 setProperty() 함수를 사용하여 address 속성을 가져오고 설정해야 합니다.
다음 코드 조각은 C++에서 QGeoAddress 객체를 가져옵니다:
QGeoAddress geoAddress = qmlObject->property("address").value<QGeoAddress>();다음 코드 조각은 C++의 QGeoAddress 객체를 기반으로 QML 객체의 address 속성을 설정합니다:
qmlObject->setProperty("address", QVariant::fromValue(geoAddress));위치 - QGeoLocation
Location.location 속성은 C++과 QML 코드 간의 인터페이스를 제공하는 데 사용됩니다. 먼저 C++에서 Location 객체에 대한 포인터를 확보한 다음, property() 및 setProperty() 함수를 사용하여 location 속성을 가져오고 설정해야 합니다.
다음 코드 조각은 C++에서 QGeoLocation 객체를 가져옵니다:
QGeoLocation geoLocation = qmlObject->property("location").value<QGeoLocation>();다음 코드 조각은 C++의 QGeoLocation 객체를 기반으로 QML 객체의 location 속성을 설정합니다:
qmlObject->setProperty("location", QVariant::fromValue(geoLocation));© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.