ColorDialog QML Type

기본 색상 대화상자. 더 보기...

Import Statement: import Qt.labs.platform
Inherits:

Dialog

속성

상세 설명

ColorDialog 유형은 네이티브 플랫폼 색상 대화 상자를 위한 QML API를 제공합니다.

색상 대화 상자를 표시하려면 ColorDialog의 인스턴스를 구성하고 원하는 속성을 설정한 다음 open()를 호출합니다. currentColor 속성은 대화 상자에서 현재 선택된 색상을 확인하는 데 사용할 수 있습니다. color 속성은 대화 상자를 수락하여 최종 선택이 이루어진 후에만 업데이트됩니다.

MenuItem {
    text: "Color"
    onTriggered: colorDialog.open()
}

ColorDialog {
    id: colorDialog
    currentColor: document.color
}

MyDocument {
    id: document
    color: colorDialog.color
}

사용 가능성

기본 플랫폼 색상 대화 상자는 현재 다음 플랫폼에서 사용할 수 있습니다:

  • iOS
  • Linux(GTK+ 플랫폼 테마로 실행하는 경우)
  • macOS

Qt Labs Platform 모듈은 기본 구현을 사용할 수 없는 플랫폼에서 Qt Widgets 을 대체로 사용합니다. 따라서 Qt Labs Platform 모듈의 유형을 사용하는 애플리케이션은 QtWidgets에 링크하고 QGuiApplication 대신 QApplication 을 사용해야 합니다.

QtWidgets 라이브러리에 링크하려면 qmake 프로젝트 파일에 다음을 추가합니다:

QT += widgets

main()QApplication 의 인스턴스를 생성합니다:

#include <QApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    return app.exec();
}

참고: Qt.labs 모듈의 유형은 향후 버전에서 호환성을 보장하지 않습니다.

속성 문서

color : color

이 프로퍼티는 최종 허용되는 색상을 저장합니다.

currentColor 속성과 달리 color 속성은 사용자가 대화 상자에서 색상을 선택하는 동안에는 업데이트되지 않고 최종 선택이 완료된 후에만 업데이트됩니다. 즉, 사용자가 OK 을 클릭하여 색상을 수락한 경우에만 업데이트됩니다. 또는 accepted() 신호를 처리하여 최종 선택 내용을 가져올 수 있습니다.

currentColoraccepted()도 참조하세요 .


currentColor : color

이 속성은 대화 상자에서 현재 선택된 색상을 유지합니다.

color 속성과 달리 currentColor 속성은 사용자가 대화 상자에서 색상을 선택하는 동안, 심지어 최종 선택이 이루어지기 전에도 업데이트됩니다.

color참조하세요 .


options : flags

이 속성에는 대화 상자의 모양과 느낌에 영향을 주는 다양한 옵션이 있습니다.

기본적으로 모든 옵션은 비활성화되어 있습니다.

대화 상자를 표시하기 전에 옵션을 설정해야 합니다. 대화 상자가 표시된 상태에서 옵션을 설정해도 옵션 및 플랫폼에 따라 대화 상자에 즉각적인 영향을 미치지는 않습니다.

사용 가능한 옵션

상수설명
ColorDialog.ShowAlphaChannel사용자가 색상의 알파 성분을 선택할 수 있도록 허용합니다.
ColorDialog.NoButtonsOKCancel 버튼을 표시하지 않습니다('라이브 대화 상자'에 유용).

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