I am trying to concatenate my copy message and the previous message. In other words, I want to paste new string wherever user wants in QTextEdit. I could insert it at the end of the string.
Here is my code:
void MessageDialog::pasteMessage()
{
QClipboard *clipboard = QApplication::clipboard();
QString previousMessage = m_messageEdit->toPlainText();
m_messageEdit->setText(previousMessage+clipboard->text());
}
It just pastes at the end of string.
I've also read it and I've tried like this:
void MessageDialog::pasteMessage()
{
QClipboard *clipboard = QApplication::clipboard();
QTextCursor cursor(m_messageEdit->textCursor());
m_messageEdit->moveCursor (QTextCursor::End);
m_messageEdit->insertPlainText (clipboard->text());
m_messageEdit->setTextCursor (cursor);
}
Actually it pastes it in a new line, which is not what I want.
Any suggestion?