在QPushButton的图片和文字之间添加space

Adding space between image and text in QPushButton

我有一个富文本按钮,它是 QPushButton 的后代,并使用 QTextDocument 来提供有限的 HTML 支持。我需要创建一个按钮,它的左边有一个图标,右边有一个标题(图像和文本之间有一些 space)。

那么,假设我们有 set_html(const QString& html) 方法。我未能通过 img 标签中的 style 属性(使用 margin)在图像和文本之间添加 space。该方法的输入字符串是什么?

您可以尝试以下详细的解决方法(由于 QLabel 中 HTML 支持有限):

<table><tr><td><img src=":/save_monitor_settings.png"/></td><td style="padding-left:10px;">Some text</td></tr></table>