What's the difference between QTextEdit
and QPlainTextEdit
, why use one over the other?
I'm coding a text editor as an exercice to learn Qt5, and now I'm wondering whether to use QTextEdit
or QPlainTextEdit
.
So far I've only found out that you can display images in QTextEdit
, but other than that they look somewhat identical to me.
My text editor should support some basic syntax highlighting (probably using textChanged()
signal), but that's pretty much as far as the requirements go.
Google searches for "QTextEdit vs QPlainTextEdit" and "QTextEdit compared to QPlainTextEdit" didn't give me any decent results that would compare the two classes.
From Qt's documentation:
And later on:
So the difference is that
QPlainTextEdit
is optimized for handling plain text, and can be used even with very large plain text files. Also the way text is formatted is simpler.If you plan to support only plain texts, then
QPlainTextEdit
is the right choice.