Online spell check editor

Qt Widgets

Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

2
Become a Fan
6.1

Description:
small adapted QTextEdit class that allows online spell cheking using aspell. For this a highlitghter class and an aspell-class is used.

The code comes in form of an example as i am not aware of how to pack the code for easier reuse.
Last changelog:

Initial functionality.
Code can handle missing aspell as well as language changes in runtime.

b) small error corrected, should now compile under linux

c) Should now work correctly under Linux with utf-8 coding. Furthermore spell correction suggestions are made for the word under the pointer instead of the word under the cursor.
These correctionn seem not to work under Linux. I will take a further look into this soon.

d) corrected error that highlights part of words that contain syntax errors. Thanks to Giuseppe Calá

e) right click now substitues word under pointr

0.2: changed spellchecking engine to hunspell which is integrated. Much faster spell checking !

0.2a: loads and saves user dictionaries automatically. Furthermore a file dialog is used to select the dictionary

0.2b: coorected an error that the context menu did not correct the selected word


Ratings & Comments

12 Comments

tpf80

Thanks, this widget was just was I was looking for as an example of adding spell checking to a QTextEdit.

sunderme

hunspell obviously needs a dictionary to work. The standard assumption is the presence of en_GB.dic in the working path. If a dictionary is present at different location, this can be set after starting the program in the options. The complete path to the *.dic file has to be set!

jiveaxe

Hi, I'm very very happy when found your code since I need it. Since I need Italian spellchecking, your code, like it is, doesn't works good with my language. I apply some modification to the code: 1) I changed line 77 of highlighter.cpp from QStringList Checkliste = str.split(QRegExp("([^a-z,^A-Z,^\\\\]|(?=\\\\))+"), to QStringList Checkliste = str.split(QRegExp("([^\\w,^\\\\]|(?=\\\\))+") so now accented letters (very common in Italian language) aren't ignored. 2) I changed line 86 of highlighter.cpp from number = text.count(str); to number = text.count(QRegExp("\\b" + str + "\\b")); and line 91 from l = text.indexOf(str,l+1); to l = text.indexOf(QRegExp("\\b" + str + "\\b"),l+1); this because if a word is misspelled and this word is a substring of a longer word than this substring is cheched as misspelled while in the new context is right (hoping I was clear...). 3) I have made the object Highlighter *highlighter a member of SpellTextEdit so the new widget SpellTextEdit is simpler to reuse. Now I have a problem with accented words which are always checked as misspelled even if they are right. I was unable to find the problem, maybe you can, knowing more deeply the code. Probably you have to install aspell-it; here are some accented Italian words: qualità maestà lealtà Regards

sunderme

What system are you using to run "spellcheck" on ? Is it windows or Linux ? And if Linux, do you know the text coding (utf-8, latin1, etc ?) Jan

jiveaxe

I use linux (Kubuntu 8.04). I have tryed with the option --encoding=utf-8 in Aspell.cpp but spellchecking doesn't works.

sunderme

okay, the problem with the accents arises from encoding. The code uses .toLatin1(...) in aspell.cpp This needs to be changed to .toLocal8Bit(...) I am going to provide new sources hopefully soon, however i have not found out yet why the suggestion of corrected word does not work under Linux.

jiveaxe

Ok, now the spellchecking works right.

sunderme

I did not understand yet why you implemented the change number 2. Could you give an example when the original code fails here ?

jiveaxe

Here is a screen: http://img134.imageshack.us/my.php?image=imgcht3.jpg The word "dell" (before the apostrophe) is wrong but the spellchecker marks wrong even 'dell' of the word "della" that is a correct word. Your code, infact, searches all occurrences of str, even if they are substring of other words; with QRegExp is matched only the whole word.

slux83

Under linux i have opened an utf-8 file and i see some weird characters! Suggestions doesn't showed

sunderme

right now the code is very simple. Therefore it takes the actual cursor position to determine of which word you want to get spelling suggestions. To get them, simply place the cursor on the respective word and do a right click ...

subratatamal

I compile the program in vista .When i right click the mouse button.Spell suggestions are not showing up

Pling
0 Affiliates
Details
license
version 0.2b
updated
added
downloads 24h 0
mediaviews 24h 0
pageviews 24h 0

Other Qt Widgets:

Widget Virtual Keyboard
embitel
last update date: 15 years ago

Score 5.3

Widget Marquee Label
embitel
last update date: 15 years ago

Score 6.1

Widget Color Picker
embitel
last update date: 15 years ago

Score 4.7

QtitanDataGrid advanced Grid for Qt
BigZ1
last update date: 8 years ago

Score 5.7

QtitanRibbon Microsoft RibbonUI and Office Styles for Qt
BigZ1
last update date: 8 years ago

Score 5.2

Q7TaskBar
QDevelopper
last update date: 13 years ago

Score 6.1