Configuration
Word prediction
Enabled by default. Disable it globally on the component or at runtime via the singleton:
VirtualKeyboard { predictionEnabled: false }
// or at runtime:
Lnvk.predictionEnabled = false
Prediction is automatically disabled for fields with Qt.ImhNoPredictiveText, Qt.ImhSensitiveData, Qt.ImhHiddenText, or any numeric, dial, date, or time hint. Read-only properties Lnvk.effectivePredictionEnabled and Lnvk.imeInteractionEnabled reflect the active hint mask (see Input method hints).
Custom prediction dictionaries
Provide domain-specific prediction dictionaries (medical, legal, product names, etc.) per language.
Step 1: Build a .pred file
Use the packaged compiler from your LNVK bundle:
# From package root
./bin/lndict-compiler --flat my-words.txt prediction-en-custom.pred
Input formats accepted by --flat:
- Word list (one word per line):
word - Word + frequency:
word<TAB>frequency - Full prediction TSV:
word<TAB>word<TAB>frequency
Word-list rows automatically get a high default frequency so custom entries rank near the top.
Step 2: Register custom dictionaries in your app
Register one dictionary per language/tag.
From QML (via the Lnvk singleton):
import Ln.VirtualKeyboard 1.0
Component.onCompleted: {
Lnvk.setCustomPredictionDictionary("en", "/opt/mydicts/prediction-en-custom.pred")
Lnvk.setCustomPredictionDictionary("en-US", "/opt/mydicts/prediction-en-us-custom.pred")
}
From C++:
#include <lnvk>
auto *kb = lnvk::qt::KeyboardManager::instance();
kb->setCustomPredictionDictionary("en", "/opt/mydicts/prediction-en-custom.pred");
kb->setCustomPredictionDictionary("en-US", "/opt/mydicts/prediction-en-us-custom.pred");
Both paths refer to the same singleton instance; calls made from C++ are visible from QML and vice versa.
Language resolution order:
- exact BCP47 tag (for example
en-US) - primary tag fallback (for example
en)
Step 3: Choose merge mode
VirtualKeyboard {
customPredictionMode: Lnvk.Supersede
}
// or on the singleton:
Lnvk.customPredictionMode = Lnvk.Supersede
From C++:
auto *kb = lnvk::qt::KeyboardManager::instance();
kb->setCustomPredictionMode(lnvk::qt::KeyboardManager::Supersede);
Modes:
Disabled: ignore custom dictionaries; use built-in onlyReplace: use custom dictionary only for matching language/tag (fallback to built-in if missing/invalid)Supersede: custom candidates first, then built-in candidates
Clear mappings at runtime:
Lnvk.clearCustomPredictionDictionary("en-US")
Lnvk.clearCustomPredictionDictionaries()
kb->clearCustomPredictionDictionary("en-US");
kb->clearCustomPredictionDictionaries();
Number row
Show a persistent row of digit keys above the letter row:
VirtualKeyboard { numberRowEnabled: true }
Lnvk.numberRowEnabled = true
Learning
The keyboard learns from typed words to improve future predictions. Disable persistence across sessions with rememberLearning:
VirtualKeyboard { rememberLearning: false }
Lnvk.rememberLearning = false
rememberLearning: false discards learned words when the application exits.
Input method hints
The keyboard adapts automatically to inputMethodHints on the focused TextInput or TextEdit:
| Hint | Layout | IME | Prediction |
|---|---|---|---|
Qt.ImhNone | Profile layout | on | on (if enabled) |
Qt.ImhDigitsOnly | Numeric keypad | off | off |
Qt.ImhDialableCharactersOnly | Dial pad | off | off |
Qt.ImhFormattedNumbersOnly | Numbers with decimal/sign | off | off |
Qt.ImhDate | Date input layout | off | off |
Qt.ImhTime | Time input layout | off | off |
Qt.ImhPreferNumbers | Numbers with letter access | off | off |
Qt.ImhEmailCharactersOnly | Email keys on alphabetic layout | off | on |
Qt.ImhUrlCharactersOnly | URL keys on alphabetic layout | off | on |
Qt.ImhNoPredictiveText | Profile layout | off | off |
Qt.ImhSensitiveData | Profile layout | off | off |
Qt.ImhHiddenText | Password mode (numeric if also sensitive) | off | off |
When IME is off, any active composition is cleared. The candidate bar remains visible for word prediction when effectivePredictionEnabled is true. When imeInteractionEnabled is true, the bar also appears during IME composition and post-commit character suggestions.