이 페이지에서

ObjectRegistry QML Type

이 유형은 키 문자열을 기반으로 나중에 액세스할 수 있도록 객체를 등록하는 데 사용됩니다. 더 보기...

Import Statement: import QtQml.DesignSupport
Since: Qt 6.12

속성

자세한 설명

객체 레지스트리는 QML 엔진 전체에 걸쳐 객체에 대한 참조를 제공합니다. 각 객체는 문자열 키로 등록되며, 이 키를 사용하여 나중에 다음 참조 유형 중 하나( ObjectRegistryRef 및 MultiObjectRegistryRef)를 통해 해당 객체를 검색할 수 있습니다. 등록된 객체에 접근하기 위한 C++ 클래스도 제공됩니다: QObjectRegistryRef 및 QMultiObjectRegistryRef.

동일한 키를 사용하여 여러 객체를 등록할 수 있습니다. 이에 대한 일반적인 사용 사례로는 목록 또는 리피터 델리게이트를 등록하는 것이 있습니다.

등록된 객체는 객체 소멸 시 또는 ObjectRegistry 인스턴스 소멸 시 레지스트리에서 자동으로 제거됩니다. 대상 객체나 키를 변경하면 레지스트리에서 이전 조합이 제거됩니다.

동일한 객체와 키 조합을 두 번 이상 등록하지 마십시오. 각 조합당 하나의 등록 정보만 저장됩니다.

등록은 등록된 객체의 첨부 속성을 사용하거나, 대상과 키를 지정하여 별도의 ObjectRegistry 객체를 사용하여 수행할 수 있습니다:

// Registering with attached property
Item {
    id: itemToRegister
    ObjectRegistry.key: "MyItem"
}

// Registering with separate ObjectRegistry object
Item {
    id: itemToRegister
    ObjectRegistry {
        target: itemToRegister
        key: "MyItem"
    }
}

ObjectRegistryRef, MultiObjectRegistryRef, QObjectRegistryRef 및 QMultiObjectRegistryRef도 참조하십시오 .

속성 문서

key : string

이 속성은 등록된 객체의 키를 지정합니다.

target : QtObject

이 속성은 등록할 대상 객체를 지정합니다.

대상 객체가 소멸되면 이 속성은 null로 재설정됩니다.

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