Hello everyone, im making an IDE for a programming language called PAWN. I have syntax highlighting down, but one problem im having is indentation. For starters tab doesnt indent correctly, so i tried using setTabStopWidth to fix this. I was worried about how it would scale when users change fonts and font sizes though, so i looked for a way to do it in a much cleaner manner than trial and error for a single font/font size.
Qt Code:
m_CodeEditor->setTabStopWidth(fontMetrics().width(" ") * 4);To copy to clipboard, switch view to plain text mode
This is what i eventually found. This was working fine for the default font, but it really doesnt seem to like when i use other custom fonts like Courier New. It should be indenting four spaces or so, but it only indenting about 2 spaces. Im not sure if i need to DO something when i set a QTextEdit's font so setTabStopWidth will work, or if the function simply doesnt work correctly. Either way, indentation is messed up with different fonts and that needs to be fixed.
My second part of the question is, how would i go about making an auto-indent like feature? Im sure its pretty simple, but i've obviously over looked it. Im not asking for code hand outs, just how i would resolve my two questions.
Bookmarks