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

To keep prediction off for some languages only, leave the global switch on and set predictionEnabled: false on those input profiles (see Languages). A profile can also turn off next-word suggestions alone with nextWordEnabled: false.

Suggestions keep each word's own casing from the dictionary (German nouns such as Haus, the English pronoun I) and add the casing you type: a capitalised first letter capitalises the suggestion, and two or more capitals in a row (caps lock) uppercase it. A word that differs from what you typed only in case is still offered (i → I, haus → Haus). Next-word suggestions after a space show the word's own casing.

Matching ignores accents you leave out: an unaccented letter also matches its accented forms (dzie → dziękuję, ecole → école, uber → über, manana → mañana), while an accented letter you type matches only itself. ß, æ and œ are not folded. Ranking stays by word frequency.

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 --lang en my-words.txt prediction-en-custom.pred

--lang <bcp47> applies the language's case rules to the display forms, the same rules the engine matches with:

  • tr, az: İ lowercases to i and I to ı, so İstanbul is stored under istanbul and Irak under ırak, and both are suggested with their capital.
  • ro: legacy cedilla ş/ţ are folded to comma-below ș/ț, rows that become duplicates have their frequencies summed, and Ș/Ț lowercase to ș/ț (Ștefan is stored under ștefan).
  • Other languages: no change.

A dictionary with such a capital is written in LNPRED-X minor 2, whose header names the --lang language; the engine sorts and searches its words by that language's rules, whatever language the file is registered for (what the user types is still folded by the registered language). LNVK releases built on lnvk-engine older than 1.6.0 reject minor 2 files.

Romanian: build custom Romanian dictionaries with --lang ro. The engine matches a typed cedilla against comma-below keys only and no longer searches stored cedilla spellings, so an unfolded .pred would miss them.

Input formats accepted by --flat:

  • Word list (one word per line): word
  • Word + frequency: word<TAB>frequency
  • Full prediction TSV: word<TAB>display<TAB>frequency, where word is the lowercase lookup key and display the suggested form (haus<TAB>Haus<TAB>900)

Word-list rows automatically get a high default frequency so custom entries rank near the top. Lookup is case-insensitive on the key; in the one- and two-column forms the word is the display form and its lowercase the key, so Paris is suggested as Paris when typing par.

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:

  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

From C++:

auto *kb = lnvk::qt::KeyboardManager::instance();
kb->setCustomPredictionMode(lnvk::qt::KeyboardManager::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()
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 data & privacy

The keyboard learns from user input to improve predictions and IME candidate ranking. By default, learned (input, word) pairs are persisted locally in plaintext (not encrypted).

Privacy: all learning is on-device. No data leaves the device: there is no telemetry and no network transmission.

What is stored

Each time the user selects a candidate or prediction, the engine records the input key (for example the typed prefix or IME reading segment) together with the chosen surface form. This history is used to boost those pairs on future lookups for the same language.

Where it is stored

Persistent files live under:

<AppDataLocation>/lnvirtualkeyboard/userfreq/<bcp47>.bin

<AppDataLocation> is the host application's writable data location (Qt QStandardPaths::AppDataLocation). There is one file per language tag (for example en.bin, zh-Hant.bin).

Opt-out and session-only mode

Persistence is controlled by rememberLearning (default true). Set it to false for session-only learning (in memory, per language; nothing is written to disk):

VirtualKeyboard { rememberLearning: false }

Lnvk.rememberLearning = false

There is no separate "clear history" API on the public QML surface. To wipe stored data, delete the userfreq directory under your application's data location, or keep rememberLearning off for kiosk and privacy-sensitive deployments.

Automatic exclusions

Learning and prediction are automatically suppressed for sensitive or special-purpose fields, regardless of rememberLearning. When inputMethodHints include any of ImhNoPredictiveText, ImhSensitiveData, ImhHiddenText, ImhDigitsOnly, ImhFormattedNumbersOnly, ImhDialableCharactersOnly, ImhDate, ImhTime or ImhPreferNumbers, the engine disables prediction (effectivePredictionEnabled is false) and IME interaction where applicable, so passwords, PINs, and numeric or date fields do not contribute to the learning store.

See also the input method hints table below.

Input method hints

The keyboard adapts automatically to inputMethodHints on the focused TextInput or TextEdit:

HintLayoutIMEPrediction
Qt.ImhNoneProfile layoutonon (if enabled)
Qt.ImhDigitsOnlyNumeric keypadoffoff
Qt.ImhDialableCharactersOnlyDial padoffoff
Qt.ImhFormattedNumbersOnlyNumbers with decimal/signoffoff
Qt.ImhDateDate input layoutoffoff
Qt.ImhTimeTime input layoutoffoff
Qt.ImhPreferNumbersSame as digits-onlyoffoff
Qt.ImhEmailCharactersOnlyEmail keys on alphabetic layoutoffon
Qt.ImhUrlCharactersOnlyURL keys on alphabetic layoutoffon
Qt.ImhNoPredictiveTextProfile layoutoffoff
Qt.ImhSensitiveDataProfile layoutoffoff
Qt.ImhHiddenTextPassword mode (numeric if also sensitive)offoff

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 suggestions.

Dictionary paths

Set LNVK_DICT_DIR to the directory that contains layouts.lnlay (typically share/lnvirtualkeyboard/dictionaries/). Binary dictionary files resolve from a storage subtree:

  • LNVK_DICT_STORAGE=compressed (default): smaller on-disk layout
  • LNVK_DICT_STORAGE=mmap: lower RSS for CJK matrix workloads

To omit prediction, n-gram, matrix, or bigram files at deploy time, use LNVK_DICT_PROFILE / LNVK_DICT_FEATURES with LNVKConfig.cmake. Details: Advanced deployment — Dictionary storage and profiles.