InputPanel QML Type
仮想キーボードのUIを提供する。詳細...
Import Statement: | import QtQuick.VirtualKeyboard |
Inherits: |
プロパティ
- active : bool
(since QtQuick.VirtualKeyboard 2.0)
- externalLanguageSwitchEnabled : bool
(since QtQuick.VirtualKeyboard 2.4)
信号
- externalLanguageSwitch(var localeList, int currentIndex)
(since QtQuick.VirtualKeyboard 2.4)
詳細説明
キーボードのサイズは利用可能な幅から自動的に計算されます。つまり、キーボードは現在のスタイルによって指定された縦横比を維持します。従って、アプリケーションはInputPanelの座標width とy のみを設定し、height は設定しないでください。
モジュールが提供する他のすべてのQMLタイプと同様に、InputPanelを使う前にQT_IM_MODULE
環境変数をqtvirtualkeyboard
に設定する必要があります。詳しくはプラグインのロードを参照してください。
注意: InputPanelのインスタンスはアプリケーション内に1つだけ持つことができます。パネルはモーダルダイアログによってブロックされることはありませんが、より高いz 値を持つアイテムによって隠されることがあります。
プロパティの説明
active : bool |
このプロパティは、入力パネルのアクティブ状態を反映します。このプロパティがtrue
の場合、キーボードはユーザーに見えるようにする必要があります。
このプロパティは、QtQuick.VirtualKeyboard 2.0 で導入されました。
externalLanguageSwitchEnabled : bool |
このプロパティは、外部言語切り替え機構を有効にします。このプロパティがtrue
の場合、仮想キーボードは内蔵言語ポップアップを表示せず、代わりにexternalLanguageSwitch シグナルを発信します。アプリケーションはこのシグナルを処理し、代わりにカスタム言語選択ダイアログを表示することができます。
このプロパティは QtQuick.VirtualKeyboard 2.4 で導入されました。
シグナルのドキュメント
このシグナルは、externalLanguageSwitchEnabled がtrue
で、ユーザーによって言語切り替えキーが押されたときに発せられます。
これは、仮想キーボードの組み込み言語ポップアップの代わりにカスタム言語ダイアログを表示するためのフックとして機能します。
localeList パラメーターには、選択できるロケール名のリストが含まれています。特定の言語に関する詳細情報を取得するには、Qt.locale ()関数を使用します。currentIndex はlocaleList の現在のロケールのインデックスです。 この項目はUIで現在の項目としてハイライトされるはずです。
新しい言語を選択するには、VirtualKeyboardSettings.locale プロパティを使用します。
以下は、カスタム言語ダイアログの実装例です:
Dialog { id: languageDialog title: "Select Input Language" modality: Qt.ApplicationModal function show(localeList, currentIndex) { languageListModel.clear() for (var i = 0; i < localeList.length; i++) { languageListModel.append({localeName: localeList[i], displayName: Qt.locale(localeList[i]).nativeLanguageName}) } languageListView.currentIndex = currentIndex languageListView.positionViewAtIndex(currentIndex, ListView.Center) languageDialog.visible = true } contentItem: ListView { id: languageListView model: ListModel { id: languageListModel function selectItem(index) { VirtualKeyboardSettings.locale = languageListModel.get(index).localeName languageDialog.visible = false } } delegate: Item { id: languageListItem width: languageNameTextMetrics.width * 17 height: languageNameTextMetrics.height + languageListLabel.anchors.topMargin + languageListLabel.anchors.bottomMargin Text { id: languageListLabel anchors.left: parent.left anchors.top: parent.top anchors.leftMargin: languageNameTextMetrics.height / 2 anchors.rightMargin: anchors.leftMargin anchors.topMargin: languageNameTextMetrics.height / 3 anchors.bottomMargin: anchors.topMargin text: languageNameFormatter.elidedText color: "#5CAA15" font { weight: Font.Normal pixelSize: 28 } } TextMetrics { id: languageNameTextMetrics font { weight: Font.Normal pixelSize: 28 } text: "X" } TextMetrics { id: languageNameFormatter font { weight: Font.Normal pixelSize: 28 } elide: Text.ElideRight elideWidth: languageListItem.width - languageListLabel.anchors.leftMargin - languageListLabel.anchors.rightMargin text: displayName } MouseArea { anchors.fill: parent hoverEnabled: true onClicked: { if (index === -1) return parent.ListView.view.currentIndex = index parent.ListView.view.model.selectItem(index) } } states: State { name: "current" when: languageListItem.ListView.isCurrentItem PropertyChanges { target: languageListLabel color: "black" } } } } }
ダイアログは次のように宣言されます:
LanguageDialog { id: languageDialog width: 400 height: 400 }
アプリケーションのInputPanel に、以下のコードを追加します:
InputPanel { id: inputPanel externalLanguageSwitchEnabled: true onExternalLanguageSwitch: languageDialog.show(localeList, currentIndex) // ... }
言語切り替えキーが押されると、カスタムダイアログが表示されます。
注: 対応するハンドラはonExternalLanguageSwitch
です。
このシグナルはQtQuick.VirtualKeyboard 2.4で導入されました。
© 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.