Qt Quick Shared Image Provider
요약
이 모듈은 여러 Qt Quick 애플리케이션이 동일한 로컬 이미지 파일을 사용하는 경우 메모리를 절약하는 기능을 제공합니다. 이는 디코딩된 QImage 데이터를 공유 시스템 메모리에 배치하여 모든 프로세스에서 액세스할 수 있도록 함으로써 이루어집니다( QSharedMemory 참조).
이 모듈은 CPU 메모리만 공유합니다. GPU 메모리나 텍스처 공유 기능은 제공하지 않습니다.
사용법
이 모듈을 사용하려면 다음과 같이 임포트하십시오:
import Qt.labs.sharedimage공유 기능은 QQuickImageProvider 를 통해 제공됩니다. 이미지의 URL 소스에는 "image:" 스키마를 사용하고, 그 뒤에 식별자 shared를 붙인 다음, 이미지 파일 경로를 입력하십시오. 예를 들면 다음과 같습니다:
Image { source: "image://shared/usr/share/wallpapers/mybackground.jpg" }이렇게 하면 /usr/share/wallpapers/mybackground.jpg 파일을 찾게 됩니다. 이 작업을 수행하는 첫 번째 프로세스는 일반적인 Qt 이미지 로딩 방식을 사용하여 이미지 파일을 읽어들입니다. 그런 다음 디코딩된 이미지 데이터는 전체 파일 경로를 키로 사용하여 공유 메모리에 저장됩니다. 나중에 동일한 이미지를 요청하는 프로세스는 해당 데이터가 이미 공유 메모리에 존재한다는 것을 감지합니다. 그러면 이미지 파일을 다시 불러오는 대신 이미 저장된 데이터를 사용하게 됩니다.
공유 이미지 데이터는 마지막 프로세스가 공유 이미지에 대한 마지막 참조를 삭제할 때까지 유지되며, 이 시점에서 자동으로 해제됩니다.
시스템 메모리 공유를 사용할 수 없는 경우, 공유 이미지 제공자는 일반적인 비공유 이미지 로딩 방식으로 전환됩니다.
파일 경로는 절대 경로여야 합니다. 상대 경로를 사용하려면 Qt.resolvedUrl() 을 사용하여 절대 경로로 변환하고 URL 스키마를 대체하십시오. 예:
...
property string imagePrefix: Qt.resolvedUrl("../myimages/").replace("file://", "image://shared/")
Image { source: imagePrefix + "myimage.png" }공유 이미지 모듈은 직접 사용할 수 있는 QML 유형을 제공하지 않습니다.
© 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.