Add cut function
This commit is contained in:
@@ -199,6 +199,16 @@ void MainWindow::on_actionEditPaste_triggered()
|
||||
|
||||
void MainWindow::on_actionEditCut_triggered()
|
||||
{
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
|
||||
|
||||
if(lineEdit) {
|
||||
QString text = lineEdit->text();
|
||||
QString selectedText = lineEdit->selectedText();
|
||||
int pos = lineEdit->selectionStart();
|
||||
text.remove(pos, selectedText.length());
|
||||
Clipboard->setText(selectedText);
|
||||
lineEdit->setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user