PyQt4 QTextEdit:HTML 表中的垂直文本



我在PyQt4/examples/demos中找到了名为Textedit的示例,它从HTML文件创建文档,我正在将其用于MS Access报告等表格报告。一切正常,但我无法在 HTML 表格中垂直设置文本。我正在尝试该代码:

<html>
<head>
<title>QTextEdit Demonstration</title>
<style type="text/css">
p.vertical{
writing-mode:tb-rl;
filter:flipH flipV;
height:60px;
</style>
</head>
<body>
<table align="center" border="1" cellpadding="4" cellspacing="0" width="99%">
<tr>
<td><p class = "vertical"><span>vertical</span></p></td>
<td><p><span>horizontal</span></p></td>
<td><p><span>0</span></p></td></tr>
</table></body></html>

浏览器中它工作正常,但是当我在文本编辑中打开它时,它不起作用。有没有另一种方法可以在文本编辑中垂直设置文本?

QTextEdit 仅支持属性的子集,请参阅此处了解支持的属性:

http://doc.qt.io/archives/qt-4.8/richtext-html-subset.html

我会推荐带有defaultStyleSheet属性的QTextDocument:

http://doc.qt.io/archives/qt-4.8/qtextdocument.html#defaultStyleSheet-prop

最新更新