이 페이지에서

C++와 QML 코드 간 인터페이스 Qt Positioning

개요

Qt Positioning 는 두 가지 방법을 사용하여 C++ 코드와 QML 코드 간의 위치 데이터 교환을 간소화합니다.

직접 매핑

Qt Positioning 을 사용하면 다음 값 유형을 QML에서 C++로 또는 그 반대로 전달할 수 있습니다:

Q배리언트 기반 통합

이 섹션에서는 QGeoAddressQGeoLocation 를 통합하는 방법에 대한 정보를 제공합니다.

주소 - QGeoAddress

Address.address 속성은 C++ 코드와 QML 코드 간의 인터페이스를 제공하는 데 사용됩니다. 먼저 C++에서 Address 객체에 대한 포인터를 가져온 다음 property() 및 setProperty() 함수를 사용하여 address 속성을 가져오고 설정해야 합니다.

다음 코드는 C++에서 QGeoAddress 객체를 가져옵니다:

 QGeoAddress geoAddress = qmlObject->property("address").value<QGeoAddress>();

다음 코드는 C++의 QGeoAddress 객체를 기반으로 QML 객체의 주소 속성을 설정합니다:

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 객체의 위치 속성을 설정합니다:

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.