xml-ph-0000@deepl.internal의 아이콘 Qt Quick Controls
Qt Quick Controls 에서는 버튼, 항목 델리게이트 및 메뉴 항목이 텍스트 레이블 외에도 아이콘을 표시할 수 있습니다.
아이콘 사용
AbstractButton Action 는 아이콘을 설정할 수 있는 다음과 같은 속성을 제공합니다:
icon.nameicon.sourceicon.widthicon.heighticon.coloricon.cache
테마 아이콘은 이름으로 참조되며, 일반 아이콘은 소스 URL로 참조됩니다. 아이콘이 항상 찾을 수 있도록 ` icon.name `과 ` icon.source `을 모두 설정할 수 있습니다. 아이콘이 테마에서 발견되면, ` icon.source `이 함께 설정되어 있더라도 항상 해당 아이콘이 사용됩니다. 아이콘이 테마에서 발견되지 않으면 대신 ` icon.source `가 사용됩니다.
Button {
icon.name: "edit-cut"
icon.source: "images/cut.png"
}각 Qt Quick Controls 2 스타일은 해당 지침에 따라 기본 아이콘 크기와 색상을 요청하지만, icon.width, icon.height 및 icon.color 속성을 설정하여 이를 재정의할 수 있습니다.
width 와 height 가 설정되지 않은 아이콘에 의해 로드되는 이미지는 사용 중인 아이콘의 유형에 따라 달라집니다. 테마 아이콘의 경우, 사용 가능한 크기 중 가장 가까운 크기가 선택됩니다. 일반 아이콘의 경우, 동작은 Image 의 sourceSize 속성과 동일합니다.
아이콘 색상은 기본적으로 다양한 상태에서 텍스트 색상과 일치하도록 지정됩니다. 아이콘을 원래 색상으로 사용하려면 색상을 "transparent" 로 설정하십시오.
Button {
icon.color: "transparent"
icon.source: "images/logo.png"
}버튼의 경우, ` display ` 속성을 사용하여 버튼 내부의 아이콘과 텍스트가 표시되는 방식을 제어할 수 있습니다.
icon.cache 속성은 아이콘 이미지가 캐시되는지 여부를 제어합니다. 자세한 내용은 cache 를 참조하십시오.
아이콘 테마
표준을 준수하는 아이콘 테마는 freedesktop 아이콘 테마 사양을 따라야 하며, 해당 사양은 http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html에서 확인할 수 있습니다.
전통적으로 리눅스와 유닉스만 플랫폼 수준에서 아이콘 테마를 지원하지만, 호환되는 아이콘 테마를 애플리케이션에 포함시켜 어떤 플랫폼에서든 테마 아이콘을 사용할 수 있습니다.
기본 icon theme search paths 는 플랫폼에 따라 다릅니다. 리눅스와 유닉스에서는, 가능한 경우 XDG_DATA_DIRS 환경 변수가 검색 경로로 사용됩니다. 모든 플랫폼에는 대체 경로로 :/icons 리소스 디렉터리가 있습니다. 사용자 정의 아이콘 테마 검색 경로는 QIcon::setThemeSearchPaths()를 사용하여 설정할 수 있습니다.
다음 예제는 Qt의 리소스 시스템을 사용하여 mytheme이라는 아이콘 테마를 애플리케이션의 리소스에 포함시킵니다.
<RCC>
<qresource prefix="/">
<file>icons/mytheme/index.theme</file>
<file>icons/mytheme/32x32/myicon.png</file>
<file>icons/mytheme/32x32@2/myicon.png</file>
</qresource>
</RCC>index.theme 파일은 아이콘 테마의 일반적인 속성을 설명하고, 사용 가능한 테마 아이콘 디렉터리를 나열합니다:
[Icon Theme]
Name=mytheme
Comment=My Icon Theme
Directories=32x32,32x32@2
[32x32]
Size=32
Type=Fixed
[32x32@2]
Size=32
Scale=2
Type=Fixed묶인 아이콘 테마를 사용하려면, 애플리케이션은 메인 QML 파일을 불러오기 전에 QIcon::setThemeName()를 호출해야 합니다:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QIcon>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QIcon::setThemeName("mytheme"); // <--
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}이제 대체 소스를 별도로 지정하지 않고도 번들된 아이콘 테마의 명명된 아이콘을 사용할 수 있습니다:
Button {
icon.name: "myicon"
}Gallery 예제와 Wearable Demo는 번들 아이콘 테마가 포함된 완전한 실행 가능 애플리케이션을 제공합니다.
© 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.