How handle the pasted file from clipboard
-
Hello, I am writing a instant message application with
QML/Qt
.
I have aTextField
as send message box. I want when the user pastes a file into theTextField
, my application uploads it.
I know maybe I could useonTextChanged
, but I'm not satisfied since the user doesn't spend most of their time copying the uploaded file. But I didn't find any signal about pasting. I tried custom shortcut key override "Ctrl+v" but it doesn't work.
Can anyone provide me with some advice? Thank you very much! -
Hi,
please, can you explain better your problem... if I understood you can do some like this :Rectangle { color: "blue" width: 100 height: 100 DropArea { anchors.fill: parent onDropped: { console.log("Something was Dropped"); console.log(clipboard.getText()) } } }
the clipboard you need to pass from C++ to qml you have examples here :
https://stackoverflow.com/questions/40092352/passing-qclipboard-to-qmlcheck this documentation QClipboard https://doc.qt.io/qt-6/qclipboard.html for more information about mechanism to copy and paste data between applications