enumeration QML Value Type
名前付き列挙値。詳細
詳細な説明
enumeration
型は名前付き列挙値を指す。
各名前付き値は、<Type>.<value>
として参照できる。例えば、Text 型はAlignRight
列挙値を持つ:
Text { horizontalAlignment: Text.AlignRight }
(後方互換性のために、列挙値は文字列として指定することもできる。この形式は新しいコードでは推奨されません)。
C++と統合する場合、C++からQMLに渡された enum
の値は自動的にenumeration
の値に変換されることに注意してください。
この値の型はQML言語が提供するものです。いくつかの列挙型の値はQtQuick のインポートによって提供されます。
QMLにおける列挙型の使用
enumeration
型は C++ のenum
型を表現したものです。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) }
© 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.