QQmlProperty Class
QQmlProperty 클래스는 QML에서 생성된 객체의 프로퍼티에 대한 액세스를 추상화합니다. 더 보기...
Header: | #include <QQmlProperty> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml) target_link_libraries(mytarget PRIVATE Qt6::Qml) |
qmake: | QT += qml |
공개 유형
enum | PropertyTypeCategory { InvalidCategory, List, Object, Normal } |
enum | Type { Invalid, Property, SignalProperty } |
공용 함수
QQmlProperty() | |
QQmlProperty(QObject *obj) | |
QQmlProperty(QObject *obj, QQmlContext *ctxt) | |
QQmlProperty(QObject *obj, QQmlEngine *engine) | |
QQmlProperty(QObject *obj, const QString &name) | |
QQmlProperty(QObject *obj, const QString &name, QQmlContext *ctxt) | |
QQmlProperty(QObject *obj, const QString &name, QQmlEngine *engine) | |
QQmlProperty(const QQmlProperty &other) | |
bool | connectNotifySignal(QObject *dest, const char *slot) const |
bool | connectNotifySignal(QObject *dest, int method) const |
bool | hasNotifySignal() const |
int | index() const |
bool | isDesignable() const |
bool | isProperty() const |
bool | isResettable() const |
bool | isSignalProperty() const |
bool | isValid() const |
bool | isWritable() const |
QMetaMethod | method() const |
QString | name() const |
bool | needsNotifySignal() const |
QObject * | object() const |
QMetaProperty | property() const |
QMetaType | propertyMetaType() const |
int | propertyType() const |
QQmlProperty::PropertyTypeCategory | propertyTypeCategory() const |
const char * | propertyTypeName() const |
QVariant | read() const |
bool | reset() const |
QQmlProperty::Type | type() const |
bool | write(const QVariant &value) const |
QQmlProperty & | operator=(const QQmlProperty &other) |
bool | operator==(const QQmlProperty &other) const |
정적 공용 멤버
QVariant | read(const QObject *object, const QString &name) |
QVariant | read(const QObject *object, const QString &name, QQmlContext *ctxt) |
QVariant | read(const QObject *object, const QString &name, QQmlEngine *engine) |
bool | write(QObject *object, const QString &name, const QVariant &value) |
bool | write(QObject *object, const QString &name, const QVariant &value, QQmlContext *ctxt) |
bool | write(QObject *object, const QString &name, const QVariant &value, QQmlEngine *engine) |
상세 설명
QML은 Qt의 메타 타입 시스템을 사용하기 때문에 기존의 모든 QMetaObject 클래스를 사용하여 QML로 생성된 객체를 내성화하고 상호 작용할 수 있습니다. 그러나 유형 안전 및 첨부 프로퍼티와 같이 QML에서 제공하는 새로운 기능 중 일부는 자연스러운 복잡성을 단순화하는 QQmlProperty 클래스를 통해 가장 쉽게 사용할 수 있습니다.
클래스 유형에서 프로퍼티를 나타내는 QMetaProperty 와 달리, QQmlProperty는 특정 객체 인스턴스에서 프로퍼티를 캡슐화합니다. 프로그래머는 프로퍼티 값을 읽으려면 QQmlProperty 인스턴스를 생성하고 read() 메서드를 호출합니다. 마찬가지로 속성 값을 쓸 때도 write() 메서드가 사용됩니다.
예를 들어 다음 QML 코드의 경우:
// MyItem.qml import QtQuick 2.0 Text { text: "A bit of text" }
Text 객체의 프로퍼티는 다음과 같이 QQmlProperty를 사용하여 액세스할 수 있습니다:
#include <QQmlProperty>#include <QGraphicsObject>...QQuickView view(QUrl::fromLocalFile("MyItem.qml"));QQmlProperty property(view.rootObject(), "font.pixelSize");qWarning() << "Current pixel size:" << property.read().toInt(); property.write(24);qWarning() << "Pixel size should now be 24:" << property.read().toInt();
회원 유형 문서
enum QQmlProperty::PropertyTypeCategory
이 열거형은 QML 프로퍼티의 범주를 지정합니다.
Constant | 값 | 설명 |
---|---|---|
QQmlProperty::InvalidCategory | 0 | 프로퍼티가 유효하지 않거나 신호 프로퍼티입니다. |
QQmlProperty::List | 1 | 속성이 QQmlListProperty 목록 속성입니다. |
QQmlProperty::Object | 2 | 속성이 QObject 파생 유형 포인터입니다. |
QQmlProperty::Normal | 3 | 프로퍼티가 일반 값 프로퍼티입니다. |
enum QQmlProperty::Type
이 열거형은 QML 프로퍼티의 유형을 지정합니다.
Constant | 값 | 설명 |
---|---|---|
QQmlProperty::Invalid | 0 | 프로퍼티가 유효하지 않습니다. |
QQmlProperty::Property | 1 | 프로퍼티가 일반 Qt 프로퍼티입니다. |
QQmlProperty::SignalProperty | 2 | 프로퍼티는 시그널 프로퍼티입니다. |
멤버 함수 문서
QQmlProperty::QQmlProperty()
잘못된 QQmlProperty를 생성합니다.
QQmlProperty::QQmlProperty(QObject *obj)
obj 의 기본 프로퍼티에 대한 QQmlProperty를 생성합니다. 기본 프로퍼티가 없으면 유효하지 않은 QQmlProperty가 생성됩니다.
QQmlProperty::QQmlProperty(QObject *obj, QQmlContext *ctxt)
context ctxt 을 사용하여 obj 의 기본 프로퍼티에 대한 QQmlProperty를 생성합니다. 기본 프로퍼티가 없으면 잘못된 QQmlProperty가 생성됩니다.
QQmlProperty::QQmlProperty(QObject *obj, QQmlEngine *engine)
engine 에서 제공하는 QML 컴포넌트 인스턴스화 환경을 사용하여 obj 의 기본 프로퍼티에 대한 QQmlProperty를 생성합니다. 기본 프로퍼티가 없으면 잘못된 QQmlProperty가 생성됩니다.
QQmlProperty::QQmlProperty(QObject *obj, const QString &name)
obj 의 name 속성에 대한 QQmlProperty를 생성합니다.
QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlContext *ctxt)
context ctxt 을 사용하여 obj 의 name 속성에 대한 QQmlProperty를 만듭니다.
컨텍스트 없이 QQmlProperty를 생성하면 첨부된 프로퍼티와 같은 일부 프로퍼티에 액세스할 수 없게 됩니다.
QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlEngine *engine)
engine 에서 제공하는 QML 컴포넌트 인스턴스화 환경을 사용하여 obj 의 name 속성에 대한 QQmlProperty 를 생성합니다.
QQmlProperty::QQmlProperty(const QQmlProperty &other)
other 의 복사본을 만듭니다.
bool QQmlProperty::connectNotifySignal(QObject *dest, const char *slot) const
프로퍼티의 변경 알림 시그널을 dest 객체의 지정된 slot 에 연결하고 참을 반환합니다. 이 메타 프로퍼티가 일반 Qt 프로퍼티를 나타내지 않거나 변경 알림 신호가 없는 경우, 또는 dest 객체에 지정된 slot 이 없는 경우 false를 반환합니다.
참고: slot 은 SLOT() 매크로를 사용하여 전달해야 올바르게 식별할 수 있습니다.
bool QQmlProperty::connectNotifySignal(QObject *dest, int method) const
프로퍼티의 변경 알림 시그널을 dest 객체의 지정된 method 에 연결하고 참을 반환합니다. 이 메타 프로퍼티가 일반 Qt 프로퍼티를 나타내지 않거나 변경 알림 신호가 없는 경우, 또는 dest 객체에 지정된 method 이 없는 경우 false를 반환합니다.
bool QQmlProperty::hasNotifySignal() const
프로퍼티에 변경 알림 신호가 있으면 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.
int QQmlProperty::index() const
프로퍼티의 Qt 메타객체 인덱스를 반환합니다.
bool QQmlProperty::isDesignable() const
프로퍼티를 디자인할 수 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
bool QQmlProperty::isProperty() const
QQmlProperty 이 일반 Qt XML 프로퍼티를 나타내는 경우 true를 반환합니다.
bool QQmlProperty::isResettable() const
프로퍼티를 재설정할 수 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
bool QQmlProperty::isSignalProperty() const
QQmlProperty 이 QML 신호 속성을 나타내는 경우 true를 반환합니다.
bool QQmlProperty::isValid() const
QQmlProperty 이 유효한 속성을 참조하면 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.
bool QQmlProperty::isWritable() const
속성이 쓰기 가능하면 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.
QMetaMethod QQmlProperty::method() const
이 속성이 SignalProperty 인 경우 QMetaMethod 을 반환하고, 그렇지 않으면 잘못된 QMetaMethod 을 반환합니다.
QString QQmlProperty::name() const
이 QML 프로퍼티의 이름을 반환합니다.
참고: 속성 이름에 대한 게터 함수입니다.
bool QQmlProperty::needsNotifySignal() const
바인딩을 최신 상태로 유지하기 위해 프로퍼티에 변경 알림 신호가 필요한 경우 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.
연결된 프로퍼티나 값이 변경되지 않는 프로퍼티와 같은 일부 프로퍼티는 변경 알림이 필요하지 않습니다.
QObject *QQmlProperty::object() const
QQmlProperty 의 QObject 을 반환합니다.
참고: 프로퍼티 객체에 대한 겟터 함수입니다.
QMetaProperty QQmlProperty::property() const
이 QML 프로퍼티와 연관된 Qt property 을 반환합니다.
QMetaType QQmlProperty::propertyMetaType() const
프로퍼티의 메타타입을 반환합니다.
propertyType도 참조하세요 .
int QQmlProperty::propertyType() const
속성의 메타타입 ID를 반환하거나 속성에 메타타입이 없는 경우 QMetaType::UnknownType 를 반환합니다.
propertyMetaType도 참조하세요 .
QQmlProperty::PropertyTypeCategory QQmlProperty::propertyTypeCategory() const
속성 카테고리를 반환합니다.
const char *QQmlProperty::propertyTypeName() const
프로퍼티의 유형 이름을 반환하거나, 유형 이름이 없는 경우 0을 반환합니다.
QVariant QQmlProperty::read() const
속성 값을 반환합니다.
[static]
QVariant QQmlProperty::read(const QObject *object, const QString &name)
object 의 name 속성 값을 반환합니다. 이 메서드는 다음과 같습니다:
QQmlProperty p(object, name); p.read();
[static]
QVariant QQmlProperty::read(const QObject *object, const QString &name, QQmlContext *ctxt)
context ctxt 을 사용하여 object 의 name 속성 값을 반환합니다. 이 메서드는 다음과 같습니다:
QQmlProperty p(object, name, context); p.read();
[static]
QVariant QQmlProperty::read(const QObject *object, const QString &name, QQmlEngine *engine)
engine 에서 제공하는 QML 컴포넌트 인스턴스화 환경을 사용하여 object 의 name 속성 값을 반환합니다. 이 메서드는 다음과 같습니다:
QQmlProperty p(object, name, engine); p.read();
bool QQmlProperty::reset() const
프로퍼티를 재설정할 수 있는 경우 프로퍼티를 재설정하고 참을 반환합니다. 프로퍼티를 재설정할 수 없는 경우 아무 일도 일어나지 않고 false가 반환됩니다.
QQmlProperty::Type QQmlProperty::type() const
프로퍼티의 유형을 반환합니다.
bool QQmlProperty::write(const QVariant &value) const
속성 값을 value 로 설정합니다. 성공하면 true
, 예를 들어 value 유형이 잘못되어 속성을 설정할 수 없는 경우 false
을 반환합니다.
[static]
bool QQmlProperty::write(QObject *object, const QString &name, const QVariant &value)
object 의 name 속성에 value 를 씁니다. 이 메서드는 다음과 같습니다:
QQmlProperty p(object, name); p.write(value);
성공하면 true
, 실패하면 false
을 반환합니다.
[static]
bool QQmlProperty::write(QObject *object, const QString &name, const QVariant &value, QQmlContext *ctxt)
context ctxt 을 사용하여 object 의 name 속성에 value 을 씁니다. 이 메서드는 다음과 같습니다:
QQmlProperty p(object, name, ctxt); p.write(value);
성공하면 true
, 그렇지 않으면 false
을 반환합니다.
[static]
bool QQmlProperty::write(QObject *object, const QString &name, const QVariant &value, QQmlEngine *engine)
engine 에서 제공하는 QML 컴포넌트 인스턴스화 환경을 사용하여 object 의 name 속성에 value 을 씁니다. 이 메서드는 다음과 같습니다:
QQmlProperty p(object, name, engine); p.write(value);
성공하면 true
, 그렇지 않으면 false
을 반환합니다.
QQmlProperty &QQmlProperty::operator=(const QQmlProperty &other)
QQmlProperty 에 other 을 할당합니다.
bool QQmlProperty::operator==(const QQmlProperty &other) const
other 와 이 QQmlProperty 가 동일한 속성을 나타내는 경우 true를 반환합니다.
© 2025 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.