View Poll Results: It's working correctly?

Voters
7. You may not vote on this poll
  • Yes

    6 85.71%
  • No

    1 14.29%
Results 1 to 8 of 8

Thread: QTextEdit with hunspell spell checker and syntax highlighter

  1. #1
    Join Date
    Jan 2010
    Posts
    3
    Qt products
    Platforms
    Windows

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

    hunspellTest.zip

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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?

  3. #3
    Join Date
    Jan 2010
    Posts
    3
    Qt products
    Platforms
    Windows

    Default 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.
    Last edited by edogen; 28th January 2011 at 16:25.

  4. #4
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

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

  5. #5
    Join Date
    Jan 2010
    Posts
    3
    Qt products
    Platforms
    Windows

    Default 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
    Last edited by edogen; 28th January 2011 at 17:27.

  6. #6
    Join Date
    Mar 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

    Qt Code:
    1. QString dictPath = "C:/temp/en_US";
    To copy to clipboard, switch view to plain text mode 

    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!

  7. #7
    Join Date
    Jan 2013
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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:

    Qt Code:
    1. QString dictFile = dictionaryPath + ".dic";
    2. QString affixFile = dictionaryPath + ".aff";
    3. QByteArray dictFilePathBA = dictFile.toLocal8Bit();
    4. QByteArray affixFilePathBA = dictFile.toLocal8Bit();
    5. _hunspell = new Hunspell(dictFilePathBA.constData(), affixFilePathBA.constData());
    To copy to clipboard, switch view to plain text mode 

    should be replaced by:

    Qt Code:
    1. QString dictFile = dictionaryPath + ".dic";
    2. QString affixFile = dictionaryPath + ".aff";
    3. QByteArray dictFilePathBA = dictFile.toLocal8Bit();
    4. QByteArray affixFilePathBA = affixFile.toLocal8Bit();
    5. _hunspell = new Hunspell(affixFilePathBA.constData(), dictFilePathBA.constData());
    To copy to clipboard, switch view to plain text mode 

    Nick
    Last edited by TNick; 12th January 2013 at 16:50. Reason: reformatted to look better

  8. #8
    Join Date
    Nov 2014
    Posts
    32
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Windows

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

Similar Threads

  1. Replies: 4
    Last Post: 11th May 2010, 17:33
  2. Is there any spell checking in QTextEdit?
    By naoyamakino in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2009, 19:57
  3. Syntax Highlighter sample is wrong
    By kib2 in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2007, 21:24
  4. QTextEdit with syntax highlighter
    By sarode in forum Qt Programming
    Replies: 2
    Last Post: 23rd October 2006, 07:20
  5. How disable auto spell checking
    By oashton in forum KDE Forum
    Replies: 1
    Last Post: 31st January 2006, 10:51

Tags for this Thread

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.