我正在尝试在 QML 中显示水平线,并支持 HTML 4 子集。
不幸的是我无法显示该行。例如下面的代码,不显示水平线。
我尝试过不同版本的hr-tag:<hr>
, <hr/>
, <hr></hr>
。但到目前为止,它们都不起作用。
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
id: root
width: 640
height: 480
visible: true
Text {
anchors.fill: parent
textFormat: Text.RichText
text: "Hello<hr>Hello"
}
}
有什么想法可以解决这个问题吗?
最佳答案
这是一个已知的错误:
https://bugreports.qt.io/browse/QTBUG-74342
您可以像这样分割富文本 block :
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
Window {
id: root
width: 640
height: 480
visible: true
ColumnLayout {
Text {
textFormat: Text.RichText
text: "Hello"
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
color: "black"
}
Text {
textFormat: Text.RichText
text: "Hello"
}
}
}
关于html - 带有 <hr> 行的 QML 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67581529/