PYQT-复制张贴功能

def copyText(self):
    clipboard = QApplication.clipboard()
    clipboard.setText("I've been clipped!")


def pasteText(self):
    clipboard = QApplication.clipboard()
    self.textLabel.setText(clipboard.text())


def copyImage(self):
    clipboard = QApplication.clipboard()
    clipboard.setPixmap(QPixmap(os.path.join(
            os.path.dirname(__file__), "images/gvim.png")))

def pasteImage(self):
    clipboard = QApplication.clipboard()
    self.imageLabel.setPixmap(clipboard.pixmap())


def copyHtml(self):
    mimeData = QMimeData()
    mimeData.setHtml("Bold and Red")
    clipboard = QApplication.clipboard()
    clipboard.setMimeData(mimeData)


def pasteHtml(self):
    clipboard = QApplication.clipboard()
    mimeData = clipboard.mimeData()
    if mimeData.hasHtml():
        self.textLabel.setText(mimeData.html())

————————————————
版权声明:本文为CSDN博主「basisworker」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiaoyangyang20/java/article/details/54706539

你可能感兴趣的:(PYQT-复制张贴功能)