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
Qt Code:
  1. private slots:
  2. void on_textEdit_clicked();
To copy to clipboard, switch view to plain text mode 

Then I added this into constructor in dialog.cpp.
Qt Code:
  1. connect(ui->textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_textEdit_clicked()));
To copy to clipboard, switch view to plain text mode 

and into dialog.cpp:
Qt Code:
  1. void Dialog::on_textEdit_clicked()
  2. {
  3. QTextCursor cursor;
  4. QString text;
  5.  
  6. cursor = ui->textEdit->textCursor();
  7. cursor.movePosition(QTextCursor::StartOfBlock);
  8. cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
  9. text = cursor.selectedText();
  10.  
  11. ui->label->setText(text);
  12.  
  13. }
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.