Results 1 to 4 of 4

Thread: Highlighting the keywords in a text edit

  1. #1
    Join Date
    Sep 2008
    Posts
    14
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question Highlighting the keywords in a text edit

    HI

    Iam a beginner in QT-C++ programming..

    Here i post this to know how to highlight the keywords in a texteditor..

    ->I want to highlight the keywords when i open a existing file

    -> wnt to highlight the keywords while typing it itself

  2. #2
    Join Date
    Aug 2008
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Highlighting the keywords in a text edit

    i think you should use QSyntaxHighlighter.

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Highlighting the keywords in a text edit

    Quote Originally Posted by divya balachandran View Post
    HI

    Iam a beginner in QT-C++ programming..

    Here i post this to know how to highlight the keywords in a texteditor..

    ->I want to highlight the keywords when i open a existing file

    -> wnt to highlight the keywords while typing it itself
    search QScintilla on google or read code from http://www.qt-apps.org/content/show....?content=59940 latest svn source ...

    To draw all QTextLine an his corresponding qrect area is not easy and and Highlightsyntax is already finisch and stable by QScintilla ...

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Highlighting the keywords in a text edit

    Several solutions exist, each with advantages and drawbacks :

    • QSyntaxHighlihter : works directly with QTextEdit but requires that you write the highlighting code yourself
    • QScintilla : replaces QTextEdit/QTextDocument/... with its own classes. Provides highligting for various programming languages but will require a bit of coding if you want highlighting for anything else than the supported languages. Crappy API. No rich text (images, frames, ...)
    • QCodeEdit : replaces QTextEdit and co. Much better API than QScintilla (at least a lot more Qt-like). Syntax highlighting can be done either programmatically or by writing a small XML file defining keywords and, if needed, contexts (i.e comments). No rich text.

    hope this helps.
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Checking max text lenght to fit in line edit?
    By maverick_pol in forum Qt Programming
    Replies: 2
    Last Post: 16th June 2008, 00:24
  3. Replies: 8
    Last Post: 15th May 2007, 09:21
  4. automatic scrolling text edit
    By Vash5556 in forum Newbie
    Replies: 2
    Last Post: 19th March 2007, 18:32
  5. Finding text on Text edit
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 18th May 2006, 13:20

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.