[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] slot of QClipboard::dataChanged() was called twice
From: "Zhao Lee" <redstone-cold () 163 ! com>
Date: 2016-08-26 15:16:28
Message-ID: 2c1df180.25e.156c76c7491.Coremail.redstone-cold () 163 ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
[Attachment #4 (text/plain)]
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@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_())
[Attachment #5 (text/html)]
<div style="color:#000; font-size: 14px;font-family: arial;"><div><span style="font-family: \
"Microsoft Yahei", ΢ÈíÑźÚ, verdana; line-height: 36px; font-size: 12px; \
background-color: rgb(255, 255, 255);">The slot of QClipboard::dataChanged() was called twice \
when I copy url in </span><span style="color: rgb(119, 119, 119); font-family: "Open \
Sans", Arial, "Lucida Grande", sans-serif; line-height: 19.5px; font-size: \
12px;">Google Chrome's address bar on Win7 </span><span style="line-height: \
23.8px;"> </span><span style="line-height: \
23.8px;">32bit</span></div><div><br></div><div><br></div><div><br></div></div><!-- \
jy5ContentSuffix --><div>ÔÚ2016Äê08Ô 26 20ʱ40·Ö, "Zhao \
Lee"<redstone-cold@163.com>дµÀ:</div><blockquote id="isReplyContent" \
style="padding-left:1ex; margin: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><div><div \
style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;">As tested With \
PyQt5.7,Python3.5 on Win7 32bit,</div><div style="color: rgb(0, 0, 0); font-family: arial; \
font-size: 14px;"><span style="line-height: 1.7;">the slot </span><span \
style="line-height: 23.8px;">detectClipboardUrl </span><span style="line-height: 1.7;">of \
QClipboard::dataChanged() was called twice </span><span style="line-height: 23.8px;">In \
this code</span><span style="line-height: 1.7;">, while I need the slot to be called only once \
, any solutions ?</span></div><div><br></div><div>import sys</div><div>from PyQt5.QtCore import \
*</div><div>from PyQt5.QtGui import *</div><div>from PyQt5.QtWidgets import \
*</div><div><br></div><div><br></div><div>class \
MainWindow(QTableView):</div><div><br></div><div> def __init__(self, \
parent=None):</div><div> super().__init__(parent)</div><div> \
self.clipboard = QApplication.clipboard()</div><div> \
self.clipboard.dataChanged.connect(self.detectClipboardUrl) \
</div><div><br></div><div> @pyqtSlot()</div><div> def \
detectClipboardUrl(self):</div><div> <span class="Apple-tab-span" \
style="white-space:pre"> </span>print('detectClipboardUrl')</div><div> <span \
class="Apple-tab-span" style="white-space:pre"> </span>clipboardText = \
self.clipboard.text()</div><div> <span class="Apple-tab-span" \
style="white-space:pre"> </span>print(clipboardText)</div><div><br></div><div><br></div><div>if \
__name__ == "__main__":</div><div> app = QApplication(sys.argv)</div><div> \
ui = MainWindow()</div><div> ui.show()</div><div> \
sys.exit(app.exec_())</div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: \
14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: \
14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: \
14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: \
14px;"><br></div></div><br><br><span \
title="neteasefooter"><p> </p></span></blockquote><br><br><span title="neteasefooter"><div \
id="netease_mail_footer"><div style="border-top:#CCC 1px solid;padding:10px \
5px;font-size:15px;color:#777;line-height:22px">ÓÊÏä¸ïÃüÀ´ÁË£¡£¡ÍøÒ×163¡¢126ÓÊÏä¿ÉÒÔ·¢ËÍ3GÒÔÉϳ¬´óÎļþ£¡</div></div></span>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic