I'm trying to copy text from Maya's script editor into a PyQt LineEdit (or any text widget for that matter).<br>
<br>
I've run into an interesting problem. If you run this widget outside 
Maya, you can copy/paste from Maya, into the line edit just fine. <br>
<b>Clipboard: text from script editor type: <class 'PyQt4.QtCore.QString'></b><br>
<br>
<br>
However, if you run it from within Maya, it hangs for a short time, and expresses nothing is available in the QClipboard....<br>
<b>Clipboard:    type: <class 'PyQt4.QtCore.QString'></b><br>
<br>
<br>
<br>
import sys<br>
from PyQt4.QtCore import *<br>
from PyQt4.QtGui import *<br>
<br>
def inMaya():<br>
    try:<br>
        import maya.cmds as mc<br>
        mc.about(application=True)<br>
        return True<br>
    except:<br>
        return False<br>
        <br>
class MyWindow(QWidget):<br>
    def __init__(self, *args):<br>
        QWidget.__init__(self, *args)<br>
        <br>
        self.le = MyLineEdit()<br>
        layout = QVBoxLayout()<br>
        layout.addWidget(self.le)<br>
        self.setLayout(layout)<br>
        <br>
class MyLineEdit(QLineEdit):<br>
    def __init__(self, *args):<br>
        QLineEdit.__init__(self, *args)<br>
        <br>
        self.obj = QLineEdit()<br>
        self.connect(self, SIGNAL('cntrlVPressed'), self.onCntrlVPressed)<br>
        <br>
    def event(self, e):<br>
        # Check if keyPressed, control is held down, and key "v" is pressed<br>
        if e.type()==QEvent.KeyPress and e.modifiers() == Qt.ControlModifier and e.key()==Qt.Key_V:<br>
            self.emit(SIGNAL('<div id=":to">cntrlVPressed'))<br>
            return True<br>
            <br>
        return QLineEdit.event(self, e)<br>
        <br>
    def onCntrlVPressed(self):<br>
        <br>
        myClipBoard = QApplication.clipboard()<br>
        pastedText = myClipBoard.text('plain', QClipboard.Selection)<br>
        <br>
        print 'Clipboard: ', pastedText, ' type:' , type(pastedText)<br>
        print<br>
        <br>
if inMaya():<br>
    w = MyWindow()<br>
    w.show()<br>
else:<br>
    app = QApplication(sys.argv)<br>
    w = MyWindow()<br>
    w.show()<br>
    sys.exit(app.exec_())
</div>