1 Attachment(s)
QTextEdit with hunspell spell checker and syntax highlighter
Hi!
I created a QTextEdit with hunspell spell checker and syntax highlighter and it allows the use of the hunspell dictionaries.
I think the project is working correctly (you can test it in the attachments, just add your language dictionary) but I read some posts about the QTextBoundaryFinder class not working correctly and I use this on my project.
Can anyone test my project and help me find if this is true.
Thanks in advance.
Attachment 5835
Re: QTextEdit with hunspell spell checker and syntax highlighter
I may have missed something, but is there any particular reason that you haven't considered using QScintilla?
Re: QTextEdit with hunspell spell checker and syntax highlighter
I didn't know about QScintilla but it seems that QScintilla is focused on code editing and my approach is for writing a text document.
Re: QTextEdit with hunspell spell checker and syntax highlighter
With regards to your text documents, do you need formatting ala Microsoft Word / OpenOffice? If so, then indeed I wouldn't expect QScintilla to be suitable for your needs.
Re: QTextEdit with hunspell spell checker and syntax highlighter
Yes, my intention was to create a QTextEdit with spell checking and syntax highlighter like Word processing software.
Added after 48 minutes:
Hi,
the project doesn't contain any dictionary. You should insert your dictionary path in "ctextcheckeredit.cpp" (dictionaries can be found in the hunspell page).
Any questions, don't hesitate to contact me.
Thanks
Re: QTextEdit with hunspell spell checker and syntax highlighter
Just to follow up on this. This is an excellent example of using Hunspell with Qt. It almost works out of the box. As edogen remarked, you need to alter the ctextcheckeredit.cpp file in order to reference a valid dictionary file. Specifically, around line 25 of ctextcheckeredit.cpp, set the dictPath value to the value to your dictionary file, and leave off the .dic of the file name. For example, you can use the en_US.dic file (download for example from here: https://github.com/rdio/vernacular/tree/master/hunspell). If you place it in the C:\temp directory (for a Windows platform), then change line 25 to
Code:
QString dictPath
= "C:/temp/en_US";
Note that since it appends a .dic on the file name somewhere in the code, then you cannot use the newer OpenOffice.org versions of the dictionaries that use the .oxt extension. Once you change that, and recompile you should have a well-functioning example. Thans to edogen for posting such a well-functioning example!
Re: QTextEdit with hunspell spell checker and syntax highlighter
Rather old thread, but, anyway,...
spellchecker.cpp contains a bug (well, two, actually) in the constructor:
Code:
QString dictFile
= dictionaryPath
+ ".dic";
QString affixFile
= dictionaryPath
+ ".aff";
QByteArray dictFilePathBA
= dictFile.
toLocal8Bit();
QByteArray affixFilePathBA
= dictFile.
toLocal8Bit();
_hunspell = new Hunspell(dictFilePathBA.constData(), affixFilePathBA.constData());
should be replaced by:
Code:
QString dictFile
= dictionaryPath
+ ".dic";
QString affixFile
= dictionaryPath
+ ".aff";
QByteArray dictFilePathBA
= dictFile.
toLocal8Bit();
QByteArray affixFilePathBA
= affixFile.
toLocal8Bit();
_hunspell = new Hunspell(affixFilePathBA.constData(), dictFilePathBA.constData());
Nick
Re: QTextEdit with hunspell spell checker and syntax highlighter
Voted. Yes - my intention was to create a QTextEdit with spell checking and syntax highlighter like Word processing software.