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
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
i think you should use QSyntaxHighlighter.
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 ...
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
Bookmarks