Offer Products Case Studies Expertises About us Contact Blog
FR EN

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
Automatic override: prediction is silently disabled for input fields with 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:

  1. exact BCP47 tag (for example en-US)
  2. 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 only
  • Replace: 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
Privacy: all learning is on-device. No data leaves the device. Setting 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:

HintKeyboard behaviour
Qt.ImhNoneFull keyboard with prediction
Qt.ImhDigitsOnlyNumeric keypad
Qt.ImhDialableCharactersOnlyDial pad
Qt.ImhFormattedNumbersOnlyNumbers with decimal and sign
Qt.ImhEmailCharactersOnlyEmail-optimised layout
Qt.ImhUrlCharactersOnlyURL-optimised layout
Qt.ImhDateDate input layout
Qt.ImhTimeTime input layout
Qt.ImhPreferNumbersNumbers with letter access
Qt.ImhNoPredictiveTextDisables word prediction
Qt.ImhSensitiveDataDisables prediction and learning
Qt.ImhHiddenTextPassword mode: no candidates shown