Qt,QPlainTextEdit和不可打印的字符 [英] Qt, QPlainTextEdit and non-printable characters

查看:803
本文介绍了Qt,QPlainTextEdit和不可打印的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能在Qt / QPlainTextEdit中以我自己的方式呈现特殊字符(例如,0-31 ASCII)?我想把它们作为一个小矩形,如截图所示: ...或者Notepad ++正在做。我的目标是能够看到所有的人物。

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.

推荐答案

如果一个字符无法用当前字体渲染(例如没有这样的字符)

Qt有办法代表 QTextEdit 和<$ c $中使用的 QTextDocument c> QPlainTextEditor 。有一个将SVG对象插入文本编辑器的示例:
http://doc.qt.io/archives/qt-4.7/richtext-textobject.html

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

或者您可以 use 您自己的中绘制各种文本对象的qt-4.7 / qabstracttextdocumentlayout.html#drawInlineObjectrel =nofollow> QAbstractTextDocumentLayout QTextDocument 。

Or you can use your own QAbstractTextDocumentLayout to handle the drawing of various text objects in the QTextDocument.

这篇关于Qt,QPlainTextEdit和不可打印的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆