Qt, QPlainTextEdit and non-printable characters

[亡魂溺海] 提交于 2019-12-12 02:19:06

问题


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.



来源:https://stackoverflow.com/questions/5226253/qt-qplaintextedit-and-non-printable-characters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!