If I insert rich text in QML TextArea, it will preserve that style (text color, underline etc.) for further inputs. Is there a way to prevent that from happening?
Example:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
TextArea {
id: textArea
textFormat: Qt.RichText
focus: true
selectByMouse: true
selectByKeyboard: true
Keys.onPressed: {
if (event.text === "@") {
textArea.text += "<a href='mentioned://user'>@User</a>";
event.accepted = true
}
}
}
}
When I enter "@" character it will insert the <a> link instead, but when I continue typing other characters it will append them to the link, as if they are a part of it. How can I continue typing a new paragraph, without appending to the link ( tag)?