简体   繁体   English

有没有办法在 QTextEdit 中显示堆叠文本

[英]Is there a way to display stacked text in QTextEdit

Is there a way to display stacked text in a QTextEdit?有没有办法在 QTextEdit 中显示堆叠文本? By stacked text, I mean fraction, or exponent通过堆叠文本,我的意思是分数或指数

例如

Is there a way to achieve this without table or html conversion?有没有办法在没有表或 html 转换的情况下实现这一目标?

Qt supports a subset of HTML in its text handling. Qt 在其文本处理中支持 HTML 的子集。 By default QTextEdit's acceptRichText property is true, so you should be able to set it's text to this:默认情况下,QTextEdit 的acceptRichText属性为真,因此您应该能够将其文本设置为:

"1<sup>1</sup>&frasl;<sub>2</sub>"

And it should display 1.5 as a fraction.它应该显示 1.5 作为分数。

AFAIK, Qt is using Unicode, and UTF-8 does have glyphs like ½ (ie U+00BD VULGAR FRACTION ONE HALF ).据我所知,Qt 使用的是 Unicode,而UTF-8确实有像 ½ 这样的字形(即U+00BD VULGAR FRACTION ONE HALF )。

However, I would indeed recommend switching to HTML.但是,我确实建议切换到 HTML。

You might also study the source code of Qt (it is open source) and subclass QTextEdit as wanted您也可以研究Qt 的源代码(它是开源的)并根据需要子类化QTextEdit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM