Search code examples
qtvariablestabsdefined

Autotabbing & Checking if variables is defined


Well. Now again, i have some questions. Basically i'm doing two things. Autotabbing which is for example when you do if() you press enter and you go to next line, but you don't do the TABS to make it appear look like this:

if(a=1)
    //Basically, the line tabbed

And the system to check if a variable is defined. Like, you do:

QString Haha = "Haha";
Haha.blabla();

Well, basically when you don't define "QString Haha" the Haha.blabla wouldnt be colored. Any idea of how to check if X variable has been defined?

Thanks!


Solution

  • If you are going to do a fully featured code editor, you really need to implement parsing of the edited programming language. And that means a lot of work. For example, QtCreator does parse C++ and QtCreator's source code is available, so you could check from that how much work is required.

    You can do a simple pattern matching syntax coloring using QSyntaxHighlighter.