Programming/qt
qt5 qml Q_PROPERTY
구차니
2026. 6. 30. 12:24
uml 외부와 내부를 연결해주려면 Q_PROPERTY를 이용해서 변수를 지정하고
해당 변수를 건드릴 함수를 연동해주면 된다.
| class UIController : public QObject { Q_OBJECT // ── 페이지 ────────────────────────────────────────────── Q_PROPERTY(int currentPage READ currentPage WRITE setCurrentPage NOTIFY currentPageChanged) // ── 센서 / 데이터 값 ──────────────────────────────────── Q_PROPERTY(double temperature READ temperature NOTIFY temperatureChanged) Q_PROPERTY(double progress READ progress NOTIFY progressChanged) // ── 텍스트 ────────────────────────────────────────────── Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged) |
[링크 : https://doc.qt.io/qt-6/qtqml-cppintegration-exposecppattributes.html]
다만 Q_PROPERTY로 연결이 가능한 타입에는 제한이 있다.
개인이 만든 구조체 등은 못 넘기는 듯?

[링크 : https://doc.qt.io/qt-6/qtqml-cppintegration-data.html]