enumeration QML Value Type

명명된 열거형 값입니다. 더 보기...

상세 설명

enumeration 유형은 명명된 열거형 값을 나타냅니다.

각 명명된 값은 <Type>.<value> 으로 참조할 수 있습니다. 예를 들어 Text 유형은 AlignRight 열거형 값을 갖습니다:

Text { horizontalAlignment: Text.AlignRight }

(이전 버전과의 호환성을 위해 열거형 값을 문자열로 지정할 수도 있습니다(예: "AlignRight"). 이 형식은 새 코드에는 권장되지 않습니다.)

C++와 통합할 때, C++에서 QML로 전달된 enum 값은 자동으로 enumeration 값으로 변환되며, 그 반대의 경우도 마찬가지입니다.

이 값 유형은 QML 언어에서 제공합니다. 일부 열거형 값은 QtQuick 가져오기를 통해 제공됩니다.

QML에서 열거형 유형 사용

enumeration 타입은 C++ enum 타입의 표현입니다. QML 자체에서는 enumeration 유형을 참조할 수 없으며, 대신 QML 코드에서 enumeration 값을 참조할 때 int 또는 var 유형을 사용할 수 있습니다.

예를 들어

import QtQuick 2.0

Item {
    // refer to Text.AlignRight using an int type
    property int enumValue: textItem.horizontalAlignment

    signal valueEmitted(int someValue)

    Text {
        id: textItem
        horizontalAlignment: Text.AlignRight
    }

    // emit valueEmitted() signal, which expects an int, with Text.AlignRight
    Component.onCompleted: valueEmitted(Text.AlignRight)
}

QML 값 유형열거형 속성도참조하세요 .

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