Programming/qt2026. 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]

'Programming > qt' 카테고리의 다른 글

qt signal / slot, connect() Qt::AutoConnection  (0) 2026.06.30
qt5 qml 다국어지원  (0) 2026.06.30
qt5 qml connections  (0) 2026.06.30
qt 동적 해상도 대응  (0) 2026.06.29
QT 다국어 지원, qm 만 교체 할수 있도록 변경  (0) 2026.06.29
Posted by 구차니