【问题标题】:How to set bottom border using css in QTextBrowser?如何在 QTextBrowser 中使用 css 设置底部边框?
【发布时间】:2020-05-07 06:25:15
【问题描述】:

假设我有一个带有以下小部件的 QT 窗口(使用 Pyside2,如 PyQT5):

import sys

from PySide2.QtWidgets import QApplication, QMainWindow, QTextBrowser

app = QApplication(sys.argv)

main_window = QMainWindow()
html_string = """
<style>
td { border-bottom: 1px solid #000000; color: blue }
</style>
<table>
  <tr>
    <td>1</td>
    <td>2</td>
  </tr>
  <tr>
    <td>3</td>
    <td>4</td>
  </tr>
</table>
"""
text_browser = QTextBrowser()
text_browser.setHtml(html_string)
text_browser.setReadOnly(True)

main_window.setCentralWidget(text_browser)

main_window.show()

exit_code = app.exec_()
sys.exit(exit_code)

我希望小部件显示带有底部边框的表格。像这样的:

(图片:带底部边框的表格)。

但我明白了:

(图片:无边框表格)。

documentation 建议在表格单元格上支持使用 css 的边框样式。

  • 注意:使用像&lt;td style="border-bottom: 1px solid #000000"&gt; 这样的内联样式没有区别。
  • 注意2:我只是想有一个底部边框,所以设置&lt;table border="1"&gt; 不会产生理想的结果。

有没有人知道这是否可以实现,如果可以,如何实现?

【问题讨论】:

  • 多么奇怪:我确实得到了底部边框:i.imgur.com/OI50tzl.png
  • @eyllanesc 谢谢,我想我得直接看看其他的东西。

标签: python css pyside2 qtextbrowser


【解决方案1】:

回答我自己的问题:

我将 PySide2-5.13.0 与 shiboken2-5.13.0 一起使用。将它们都更新到 5.14.0 后,它现在可以按预期工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多