最近Qt 5.14在此版本中已发布,它们具有added support for the Markdown format。
在Text和TextEdit中添加了对Markdown格式(包括CommonMark和GitHub方言)的支持,以替代HTML。这包括GitHub清单扩展名,允许在TextEdit中切换复选框。
我希望可以在TextEdit或Text中输入文本,而我的文本看起来像this。您可能在Discord或StackOverflow中看到的结果相同。
但是我对此有疑问。我找不到任何文档或任何有关如何使用它的参考。我以为可以在TextEdit textFormat或Text textFormat中找到信息,但是只有旧的html标签(它们是replaced by Markdown format)。
这是我的代码的一部分,如果需要的话。 (代码可能是错误的,因为更改后我尚未对其进行测试。)
import QtQuick 2.14
import QtQuick.Controls 2.14
Item {
width: 100
height: 100
Text {
id: messageText
height: 50
width: 100
text: msgLine.text
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
textFormat: Text.StyledText
font.pointSize: 13
lineHeight: 1.15
anchors.top: parent.top
}
TextEdit {
id: msgLine
height: 50
width: 100
anchors.top: messageText.bottom
Text.RichText // I have changed this value to others
verticalAlignment: Text.AlignVCenter
TextEdit.WrapAtWordBoundaryOrAnywhere
}
}
我想问一下是否有任何有关如何使用它的文档或任何示例。预先感谢!
这似乎是Qt文档(QTBUG-80749)的错误,如果要在Text
或Text
中使用markdown,则必须在TextEdit
属性中设置TextEdit
:
TextEdit.MarkdownText
textFormat