Switch QML Type
オンとオフを切り替えられるスイッチボタン。詳細...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
プロパティ
- position : real
- visualPosition : real
詳細な説明
スイッチは、ドラッグしたり、オン(チェック)またはオフ(チェックなし)に切り替えたりできるオプションボタンです。スイッチは通常、2つの状態から選択するために使用されます。リスト内のような多数の選択肢がある場合は、代わりにSwitchDelegate の使用を検討してください。
Switchは、AbstractButton からAPIを継承しています。たとえば、checked プロパティを使用してスイッチの状態を設定できます。clicked およびAbstractButton::toggled シグナルは、ユーザーがタッチ、マウス、またはキーボードを介してスイッチをインタラクティブにクリックしたときに発火します。
ColumnLayout {
Switch {
text: qsTr("Wi-Fi")
checked: Networking.wifiEnabled
onClicked: Networking.wifiEnabled = checked
}
Switch {
text: qsTr("Bluetooth")
checked: Networking.bluetoothEnabled
onClicked: Networking.bluetoothEnabled = checked
}
}「スイッチおよびボタン コントロールのカスタマイズ」も参照してください 。
プロパティのドキュメント
position : real [read-only]
このプロパティは、サムインジケーターの論理的な位置を保持します。
この位置は、インジケーターのサイズに対する割合として、0.0 ~1.0 の範囲で表されます。この位置は、例えば、サムが中間点を過ぎたかどうかを判断するために使用できます。サムインジケーターを視覚化するには、代わりに右から左への読み込みに対応したvisualPosition を使用する必要があります。
visualPositionも参照してください 。
visualPosition : real [read-only]
このプロパティは、サムインジケーターの表示位置を保持します。
位置は、インジケータのサイズに対する割合として、0.0 ~1.0 の範囲で表されます。コントロールがmirrored の場合、値は1.0 - position となります。これにより、右から左への読み込みに対応したサムインジケータの視覚化に適した値となります。 例えば、サムが中間点を越えてドラッグされたかどうかを判定するには、代わりに論理値 `position ` を使用する必要があります。
positionも参照してください 。
© 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.