I wonder if there is any possibility to render special characters (0-31 ASCII, for example) my own way in Qt/QPlainTextEdit? I want to render them as small rectangles as seen in this screenshot: ...or as Notepad++ is doing it. My goal is to be able see all characters. So if a character fails to render with current font (there is no such char for example), a small square should be rendered instead.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Qt does have ways to represent non-characters in QTextDocument
which is used in QTextEdit
and QPlainTextEditor
. There's a sample on inserting an SVG object into a text edit:
http://doc.qt.io/archives/qt-4.7/richtext-textobject.html
Or you can use your own QAbstractTextDocumentLayout
to handle the drawing of various text objects in the QTextDocument
.