Hi,
I have a QML TextArea (RichText), where I append an image from resources (using HTML <img>)
After appending, the cursor goes automatically to 0, although I set
textArea.cursorPosition = textArea.text.length
textArea.cursorPosition = textArea.text.length
To copy to clipboard, switch view to plain text mode
How can I keep the cursor at the end, to keep writing?
My code:
import QtQuick 2.7
import QtQuick.Controls 1.3
Item {
height: 600
width: 600
anchors.centerIn: parent
TextArea {
id: textArea
anchors.centerIn: parent
height: 300
width: 500
textFormat: TextEdit.RichText // diego.donate
verticalAlignment: TextEdit.AlignVCenter
font. pointSize: 14
horizontalAlignment: Text.AlignLeft
}
DropArea {
anchors.fill: textArea
onEntered: drag.accepted = true
onDropped: {
var sImageFromRes = "qrc:///images/image.png"
textArea.text += "<img src=" + sImageFromRes + " height=25 width=25>"
textArea.cursorPosition = textArea.text.length // NOT working
}
}
}
import QtQuick 2.7
import QtQuick.Controls 1.3
Item {
height: 600
width: 600
anchors.centerIn: parent
TextArea {
id: textArea
anchors.centerIn: parent
height: 300
width: 500
textFormat: TextEdit.RichText // diego.donate
verticalAlignment: TextEdit.AlignVCenter
font. pointSize: 14
horizontalAlignment: Text.AlignLeft
}
DropArea {
anchors.fill: textArea
onEntered: drag.accepted = true
onDropped: {
var sImageFromRes = "qrc:///images/image.png"
textArea.text += "<img src=" + sImageFromRes + " height=25 width=25>"
textArea.cursorPosition = textArea.text.length // NOT working
}
}
}
To copy to clipboard, switch view to plain text mode
Thanks,
Diego
Bookmarks