Hi, I am very beginner myself but I tested out what Lykurg said and it works.
I created QTextEdit and QLabel with QTCreator UI editor (based on QDialog).
Added this to dialog class in header
private slots:
void on_textEdit_clicked();
private slots:
void on_textEdit_clicked();
To copy to clipboard, switch view to plain text mode
Then I added this into constructor in dialog.cpp.
connect(ui->textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_textEdit_clicked()));
connect(ui->textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_textEdit_clicked()));
To copy to clipboard, switch view to plain text mode
and into dialog.cpp:
void Dialog::on_textEdit_clicked()
{
cursor = ui->textEdit->textCursor();
text = cursor.selectedText();
ui->label->setText(text);
}
void Dialog::on_textEdit_clicked()
{
QTextCursor cursor;
QString text;
cursor = ui->textEdit->textCursor();
cursor.movePosition(QTextCursor::StartOfBlock);
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
text = cursor.selectedText();
ui->label->setText(text);
}
To copy to clipboard, switch view to plain text mode
Sorry, I dont use python. So you've got to translate it yourself.
Works great. I however expected the line to turn blue to indicate selection but this did not happen.
Bookmarks