이 페이지에서

유효 기간이 지난 속성 읽기

qmllint에서는 이 경고 범주를 ' [stale-property-read] '로 표기합니다.

상수가 아니며 알림 대상이 아닌 속성 읽기

무슨 일이 발생했나요?

상수가 아니면서 알림 대상이 아닌 속성이 바인딩에서 사용되었습니다.

왜 문제가 될까요?

상수 속성은 값이 절대 변하지 않습니다. 알림 가능 속성은 값이 변경될 때 이에 의존하는 바인딩에 알림을 보내 바인딩이 재평가될 수 있도록 합니다.

이 속성은 상수도 아니고 알림 가능 속성도 아니기 때문에, 프로그램 실행 중에 값이 변경되어도 의존하는 바인딩에 알리지 않을 수 있습니다. 이로 인해 바인딩의 값이 해당 속성에 의존하게 되므로, 바인딩이 잠재적으로 오래된 상태로 남게 될 수 있습니다.

예시

class Circle : public QObject
{
    Q_OBJECT
    QML_ELEMENT
    Q_PROPERTY(double radius READ radius WRITE setRadius FINAL)
public:
    double radius() const { return m_radius; }
    void setRadius(double radius) { m_radius = radius; }
private:
    double m_radius = 1;
};
import QtQuick

Item {
    Circle {
        id: circle
        property double area: Math.PI * radius * radius
    }

    Component.onCompleted: {
        console.log(circle.area) // 3.14159...
        circle.radius = 2
        console.log(circle.area) // 3.14159...
    }
}

이 경고를 해결하려면, 속성의 값이 변하지 않을 경우 해당 속성을 상수로 지정하거나, 알림 가능 속성으로 설정하십시오.

class Circle : public QObject
{
    Q_OBJECT
    QML_ELEMENT
    Q_PROPERTY(double radius READ radius WRITE setRadius NOTIFY radiusChanged FINAL)
public:
    double radius() const { return m_radius; }
    void setRadius(double radius) {
        if (radius != m_radius) {
            m_radius = radius;
            emit radiusChanged();
        }
    }
signals:
    void radiusChanged();
private:
    double m_radius = 1;
};
import QtQuick

Item {
    Circle {
        id: circle
        property double area: Math.PI * radius * radius
    }

    Component.onCompleted: {
        console.log(circle.area) // 3.14159...
        circle.radius = 2
        console.log(circle.area) // 12.5663...
    }
}

© 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.