ActionGroup QML Type
アクションをグループ化します。詳細...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
プロパティ
- actions : list<Action>
- checkedAction : Action
- enabled : bool
- exclusive : bool
関連するプロパティ
- group : ActionGroup
信号
- triggered(Action action)
方法
- void addAction(Action action)
- void removeAction(Action action)
詳細説明
ActionGroupは、非視覚的なアクションのグループです。相互に排他的(exclusive )なアクショングループは、一度に1つのオプションしか選択できないアクションで使用されます。
ActionGroup を使用する最も簡単な方法は、アクションをグループの子として宣言することです。
ActionGroup {
id: alignmentGroup
Action {
checked: true
checkable: true
text: qsTr("Left")
}
Action {
checkable: true
text: qsTr("Center")
}
Action {
checkable: true
text: qsTr("Right")
}
}あるいは、group 添付プロパティを使用することで、別の場所でアクションを宣言し、それらを特定のグループに割り当てることも可能です。
ActionGroup { id: alignmentGroup }
Action {
checked: true
checkable: true
text: qsTr("Left")
ActionGroup.group: alignmentGroup
}
Action {
checkable: true
text: qsTr("Center")
ActionGroup.group: alignmentGroup
}
Action {
checkable: true
text: qsTr("Right")
ActionGroup.group: alignmentGroup
}より高度なユースケースについては、addAction() およびremoveAction() メソッドを使用して処理できます。
「 Action 」および「ButtonGroup 」も参照してください 。
プロパティのドキュメント
actions : list<Action> [default]
このプロパティには、グループ内のアクションのリストが格納されます。
「group」も参照してください 。
checkedAction : Action
このプロパティは、排他グループ内の現在選択されているアクションを保持します。排他グループが存在しない場合、またはグループが非排他グループである場合は、null を保持します。
デフォルトでは、排他的なアクショングループに追加された、最初にチェックされたアクションとなります。
「exclusive」も参照してください 。
enabled : bool
このプロパティは、アクショングループが有効かどうかを表します。デフォルト値は「true 」です。
このプロパティがfalse の場合、グループ内のすべてのアクションは無効になります。このプロパティがtrue の場合、明示的に無効にされていない限り、グループ内のすべてのアクションが有効になります。
exclusive : bool
このプロパティは、アクショングループが排他的なかどうかを示します。デフォルト値は「true 」です。
このプロパティがtrue に設定されている場合、グループ内のアクションは一度に1つしかチェックできません。ユーザーは任意のアクションをトリガーしてチェック状態にすることができ、そのアクションがグループ内の既存のチェック済みアクションに取って代わります。
排他的なグループでは、ユーザーは現在チェックされているアクションをトリガーしてチェックを解除することはできません。代わりに、そのグループの新しいチェック対象アクションを設定するには、グループ内の別のアクションをトリガーする必要があります。
非排他グループでは、アクションのチェックやチェック解除は、グループ内の他のアクションに影響を与えません。さらに、checkedAction プロパティの値はnull です。
添付のプロパティのドキュメント
ActionGroup.group : ActionGroup [attached]
このプロパティは、アクショングループにアクションを関連付けます。
ActionGroup { id: group }
Action {
checked: true
text: qsTr("Option A")
ActionGroup.group: group
}
Action {
text: qsTr("Option B")
ActionGroup.group: group
}「actions」も参照してください 。
Signal ドキュメント
triggered(Action action)
このシグナルは、グループ内のaction がトリガーされたときに発せられます。
このシグナルは、同じグループ内のすべてのアクションに対して共通のシグナルハンドラを実装するのに便利です。
ActionGroup {
onTriggered: console.log("triggered:", action.text)
Action { text: "First" }
Action { text: "Second" }
Action { text: "Third" }
}注: 対応するハンドラは onTriggered です。
Action::triggered()も参照してください 。
メソッドのドキュメント
void addAction(Action action)
アクショングループに「action 」を追加します。
注: 通常、アクショングループにオブジェクトを手動で 追加する必要はありません。「actions 」プロパティおよび「group 」アタッチドプロパティを使用することで、便利で宣言的な構文を利用できます。
「 actions 」および「group 」も参照してください 。
void removeAction(Action action)
アクショングループから「action 」を削除します。
© 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.