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
Qt.ImhNoPredictiveText or Qt.ImhSensitiveData hints regardless of this setting.
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 = lenewt::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
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()
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 its layout automatically to the inputMethodHints of the focused TextInput or TextEdit:
| Hint | Keyboard behaviour |
|---|---|
Qt.ImhNone | Full keyboard with prediction |
Qt.ImhDigitsOnly | Numeric keypad |
Qt.ImhDialableCharactersOnly | Dial pad |
Qt.ImhFormattedNumbersOnly | Numbers with decimal and sign |
Qt.ImhEmailCharactersOnly | Email-optimised layout |
Qt.ImhUrlCharactersOnly | URL-optimised layout |
Qt.ImhDate | Date input layout |
Qt.ImhTime | Time input layout |
Qt.ImhPreferNumbers | Numbers with letter access |
Qt.ImhNoPredictiveText | Disables word prediction |
Qt.ImhSensitiveData | Disables prediction and learning |
Qt.ImhHiddenText | Password mode: no candidates shown |