如何获取在富文本中被点击的图片?
How to get the image which is clicked in rich text?
有QML写的实时通讯工具,消息以html格式传输
simple code:
Rectangle{
width:300
height: 300
Rectangle{ // simple bubble
anchors.centerIn: parent
width: parent.width-100
height: parent.height-100
color:"#f0f0f0"
radius: 10
TextEdit { //simple message show
anchors.fill: parent
readOnly: true
selectByMouse: true
clip: true
text: "<!DOCTYPE html>
<html>
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head>
<body style=\"font-family:Geneva,Helvetica,Arial,sans-serif; font-size: 12px;\">
this is an image:
<img alt=\"\" src=\"file:/local/image.png\" />
</body>
</html>
"
textFormat: Text.RichText
}
}
}
我的问题是如何从 BubbleChatWidget 中获取点击图像?
喜欢:
click action
类似问题:here
当我参考Telegram(web)时,我发现Telegram消息不会有文字和图片在一起。 link
您可能会事先解析文本,并将每个图像包装在 link <a ...>...</a>
.
中
这样您就可以使用 linkActivated(link)
信号来注册点击。
查看文档:
有QML写的实时通讯工具,消息以html格式传输
simple code:
Rectangle{
width:300
height: 300
Rectangle{ // simple bubble
anchors.centerIn: parent
width: parent.width-100
height: parent.height-100
color:"#f0f0f0"
radius: 10
TextEdit { //simple message show
anchors.fill: parent
readOnly: true
selectByMouse: true
clip: true
text: "<!DOCTYPE html>
<html>
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head>
<body style=\"font-family:Geneva,Helvetica,Arial,sans-serif; font-size: 12px;\">
this is an image:
<img alt=\"\" src=\"file:/local/image.png\" />
</body>
</html>
"
textFormat: Text.RichText
}
}
}
我的问题是如何从 BubbleChatWidget 中获取点击图像?
喜欢: click action
类似问题:here
当我参考Telegram(web)时,我发现Telegram消息不会有文字和图片在一起。 link
您可能会事先解析文本,并将每个图像包装在 link <a ...>...</a>
.
这样您就可以使用 linkActivated(link)
信号来注册点击。
查看文档: