PDA

View Full Version : An Editor for source view - help



QuTe
18th November 2008, 10:33
hi,

I'm a newbie to Qt stuff. Currently I'm developing an application which displayes the source [i.e. code snippet from source files] code, within is its workspace, when triggered. I wanted to know, which class would be better to use for this purpose. I'm thinking of utilizing QTextEdit. But I'm also interested in showing the source code with proper indentation and, if possible, with stylised color display, like that of Linux Console/Vi editor. is that possible with QTextEdit? How?. Basically a simple source viewer editor app.
oh, btw, I'm using Qt 3.3, and I'm not to upgrade to Qt 4.x, because rest of the code is in Qt 3.3, with which I'll have to cope.
I'd really appreciate, if any of you will guide me in this regard or will point me to the right material/examples on this topic.

Thanks for spending time.

pastor
18th November 2008, 13:59
You can use QSyntaxHighlighter for that.

QuTe
19th November 2008, 07:11
Thank you pastor for that valuable suggestion.
I'll surely look into it.


I've another problem, though. I'm intending to put the cursor, on opening of the source code in the editor, at a particular line number, in order to point out the function call or function name or variable declaration, which is the intention of showing up of source code [ since user would be directed to the point in the source code where he is interested in, when source code is displayed].
With the help of setCursorPosition() I'm able to move my cursor to a particular line number I wish to highlight. But I'm unable to place the cursor 'at' the real code, since it gets placed at the first index or 0th column[ for example, in case of indentation the code line would be tabbed from the first column, so the cursor will be at the start of the line and not at the start of the code!]

I'd really appreciate if anyone of you'll guide me and help me in this matter.

Thanks for spending the time.