Results 1 to 13 of 13

Thread: Adding spell checking to lineedits, textedits, ...

  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Adding spell checking to lineedits, textedits, ...

    Hi,
    exists some qt class which adds spell checking to editable fields like lineedits or textedits; i don't found anything in the documentation. My needs are very poor: a simple mark on the wrong word (not correction feature).

    Thanks
    Giuseppe CalÃ

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding spell checking to lineedits, textedits, ...

    You can go with aspell: http://aspell.net/.

  3. #3
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Adding spell checking to lineedits, textedits, ...

    by any chance do you have any tutorial of how to integrate Aspell to QT QtextEdit???

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adding spell checking to lineedits, textedits, ...

    Implement a syntax hghlighter that calls ASpell for each word using this API for example: http://aspell.net/man-html/Through-t...ough-the-C-API

  5. #5
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding spell checking to lineedits, textedits, ...

    I found this project

    Online spell check editor

    which suit my needs. If needed I can give you some code for help.
    Giuseppe CalÃ

  6. The following user says thank you to jiveaxe for this useful post:

    arturo182 (10th April 2009)

  7. #6
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Adding spell checking to lineedits, textedits, ...

    Thx, if you can do that I REALLY APPRECIATE!!!

  8. #7
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding spell checking to lineedits, textedits, ...

    First list of attachments...
    Attached Files Attached Files
    Giuseppe CalÃ

  9. #8
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding spell checking to lineedits, textedits, ...

    Put all these files in your project src dir (see attachment in this and my previous post):

    spelltextedit.h
    spelltextedit.cpp
    highlighter.h
    highlighter.cpp
    Aspell.h
    Aspell.cpp
    ThreadQueue.h
    ThreadQueue.cpp

    Now you can reuse the new widget SpellTextEdit like a normal QTextEdit, just "#include spelltextedit.h".

    This code is different from that in the last version of "Online spell check editor"; this uses aspell instead of hspell; more: the language is hardcoded in highlighter.h so if needed look there.

    Regards
    Attached Files Attached Files
    Giuseppe CalÃ

  10. #9
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Adding spell checking to lineedits, textedits, ...

    This needs something else from aspell?

  11. #10
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding spell checking to lineedits, textedits, ...

    Quote Originally Posted by smarinr View Post
    This needs something else from aspell?
    All you need is aspell program, no libs.

    Bye
    Giuseppe CalÃ

  12. #11
    Join Date
    May 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding spell checking to lineedits, textedits, ...

    Can you please elaborate how to use these files within project. I want to add spell checking functionality to my QtextEdit.

  13. #12
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding spell checking to lineedits, textedits, ...

    Simply use SpellTextEdit instead of QTextEdit (remember to edit highlighter.h for setting your language). Just a little example:

    Qt Code:
    1. #include <QApplication>
    2. #include "spelltextedit.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. SpellTextEdit *spellTextEdit = new SpellTextEdit;
    8. spellTextEdit->show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Attached are 2 files; use these instead of those in my previous posts;

    Bye
    Attached Files Attached Files
    Giuseppe CalÃ

  14. #13
    Join Date
    Oct 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding spell checking to lineedits, textedits, ...

    ---<summary>---
    QtWebKit doesn't mark (underline with red wavy line) misspelled words
    while in designMode even if spell checking is implemented and works
    correctly. Could you please point me what I am doing wrong?
    I'm building arora with QtWebKit (actually, entire qt 4.6.0 tp1
    downloaded from qt web site as tarball) using Visual Studio 2005 SP1
    under English WIndows XP SP3.
    ---</summary>---

    Recently I have been interested in embedding QtWebKit in my project as
    webbrowser plugin. I looked around the web and found arora excellent
    example for implementing code that covers my needs. But I'm also need
    to enable spell checking in QtWebkit. To do so I've taken another look
    at Google Chrome source code that might use hunspell to enable
    spellchecking in browser and found some clues. I have rewritten
    Chromium's code and replaced following functions in
    Qt Code:
    1. qt-4.6.0-tp1\src\3rdparty\webkit\WebKit\qt\WebCoreSupport\EditorClientQt.cpp
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void EditorClientQt::checkSpellingOfString(const UChar* str, int length,
    2. int* misspellingLocation,
    3. int* misspellingLength)
    4. {
    5. // Original
    6. // notImplemented();
    7. return MySpellChecker::getInstance()->checkSpellingOfString(str,
    8. length, misspellingLocation, misspellingLength);
    9. }
    10.  
    11. bool EditorClientQt::isContinuousSpellCheckingEnabled()
    12. {
    13. // Original
    14. // return false;
    15. return true;
    16. }
    17.  
    18. String EditorClientQt::getAutoCorrectSuggestionForMisspelledWord(const
    19. String &word)
    20. {
    21. //Original
    22. //notImplemented();
    23. //return String();
    24. return MySpellChecker::getInstance()->getAutoCorrectSuggestionForMisspelledWord(word);
    25. }
    To copy to clipboard, switch view to plain text mode 
    MySpellChecker is spellchecker that using hunspell. I've built
    QtWebKit and placed breakpoints inside bodies of functions mentioned
    above. As far as I can see functions are being invoked correctly, i.e.
    if I, for example, write "cra is moving", it is being corrected by
    getAutoCorrectSuggestionForMisspelledWord as "car is moving", but if i
    write "car is asdf" then the word "asdf" is just not being marked as
    misspelled word. Could you please point me what I am doing wrong?

    I'm building arora with QtWebKit (actually, entire qt 4.6.0 tp1
    downloaded from qt web site as tarball) using Visual Studio 2005 SP1
    under English WIndows XP SP3.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.