[PyQt] slot of QClipboard::dataChanged() was called twice
Zhao Lee
redstone-cold at 163.com
Fri Aug 26 16:16:28 BST 2016
The slot of QClipboard::dataChanged() was called twice when I copy url in Google Chrome's address bar on Win7 32bit
在2016年08月26 20时40分, "Zhao Lee"<redstone-cold at 163.com>写道:
As tested With PyQt5.7,Python3.5 on Win7 32bit,
the slot detectClipboardUrl of QClipboard::dataChanged() was called twice In this code, while I need the slot to be called only once , any solutions ?
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MainWindow(QTableView):
def __init__(self, parent=None):
super().__init__(parent)
self.clipboard = QApplication.clipboard()
self.clipboard.dataChanged.connect(self.detectClipboardUrl)
@pyqtSlot()
def detectClipboardUrl(self):
print('detectClipboardUrl')
clipboardText = self.clipboard.text()
print(clipboardText)
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = MainWindow()
ui.show()
sys.exit(app.exec_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160826/f4d93715/attachment.html>
More information about the PyQt
mailing list