i have an action called bold, when i select text then run this action this code will run:
void MarkEditWindow::on_actionBold_triggered()
{
QTextCursor selectionBegin
(ui
->markdownEdit
->document
());
selectionBegin.setPosition(ui->markdownEdit->textCursor().anchor());
selectionBegin.insertText("**");
QTextCursor selectionEnd
(ui
->markdownEdit
->document
());
selectionEnd.setPosition(ui->markdownEdit->textCursor().position());
selectionEnd.insertText("**");
}
void MarkEditWindow::on_actionBold_triggered()
{
QTextCursor selectionBegin(ui->markdownEdit->document());
selectionBegin.setPosition(ui->markdownEdit->textCursor().anchor());
selectionBegin.insertText("**");
QTextCursor selectionEnd(ui->markdownEdit->document());
selectionEnd.setPosition(ui->markdownEdit->textCursor().position());
selectionEnd.insertText("**");
}
To copy to clipboard, switch view to plain text mode
now for example i wrote “test†then run the action the result is “test†and the selected text will be “test**†(missing first ‘**’)
how can i move the cursor after selection to make it select “test†or even select “test†only
i tried a lot of things and didn’t work, like:
selectionEnd.movePosition(QTextCursor::Left);
selectionEnd.movePosition(QTextCursor::Left);
To copy to clipboard, switch view to plain text mode
but didn’t work! :-(
Bookmarks