SpellChecker

Since: BlackBerry 10.0.0

#include <bb/utility/SpellChecker>

To link against this class, add the following line to your .pro file: LIBS += -lbbutility

Verifies the spelling of words and offers spelling suggestions.

The SpellChecker class uses the system spell check and the current system locale to verify spelling and providing suggestions.

Here's an example of how to implement functions that use SpellChecker to check the spelling of a word and return a list of spelling suggestions:

bool checkSpelling(QStringList const & words)
{
    bool res = true;
    bb::utility::SpellChecker spellChecker;
    Q_FOREACH(QString const & word, words) {
        res = res && spellChecker.checkWord(word);
    }
    return res;
}

QStringList getSomeSuggestions(QString const & word)
{
    bb::utility::SpellChecker spellChecker;
    return spellChecker.suggestions(word, 5);
}

When using a TextArea or TextField, spell check can be enabled by default on text that's provided by the user, depending on the input mode that's used. The input modes for a TextArea and TextField are specified using the TextAreaInputMode and TextFieldInputMode classes, respectively.


Overview

Public Functions Index

SpellChecker (QObject *parent=0)
virtual ~SpellChecker ()
Q_INVOKABLE boolcheckWord (const QString &word, bool *ok=0, int millisecondTimeout=1000)
Q_INVOKABLE QStringListsuggestions (const QString &word, int limit=0, bool *ok=0, int millisecondTimeout=1000)

Public Functions

SpellChecker (

Creates a new instance of the SpellChecker class.

Parameters
parent

The parent of the instance.

Since:

BlackBerry 10.0.0

virtual~SpellChecker ()

Destructor.

Since:

BlackBerry 10.0.0

Q_INVOKABLE bool checkWord (
  • const QString &word,
  • bool *ok,
  • intmillisecondTimeout )

Checks whether the specified word is spelled correctly.

The check is performed based on the current system locale.

Parameters
word

The word to be checked.

ok

If not specified, ok is set to true if the check completed successfully, and false otherwise (for example, on a timeout).

millisecondTimeout

The maximum time, in milliseconds, to wait for an answer from the service.

Return:

true if the word is spelled correctly, false otherwise. This function also returns false if an error occurred. You can use the ok parameter to check for errors.

Since:

BlackBerry 10.0.0

Q_INVOKABLE QStringList suggestions (
  • const QString &word,
  • intlimit,
  • bool *ok,
  • intmillisecondTimeout )

Retrieves spelling suggestions for the specified word.

The number of results can be limited by specifying a limit.

The check is performed based on the current system locale.

Parameters
word

The word to be checked.

limit

The maximum number of results to return. If 0 or less, the limit is ignored.

ok

If not specified, ok is set to true if the check completed successfully, and false otherwise (for example, on a timeout).

millisecondTimeout

The maximum time, in milliseconds, to wait for an answer from the service.

Return:

A list of spelling suggestions for the specified word. Returns an empty list if an error occurred. You can use the ok parameter to check for errors.

Since:

BlackBerry 10.0.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus