[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: \
&quot;Microsoft Yahei&quot;, ΢ÈíÑźÚ, 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: &quot;Open \
Sans&quot;, Arial, &quot;Lucida Grande&quot;, sans-serif; line-height: 19.5px; font-size: \
12px;">Google Chrome's address bar on Win7&nbsp;</span><span style="line-height: \
23.8px;">&nbsp;</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"&lt;redstone-cold@163.com&gt;дµÀ:</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&nbsp;slot&nbsp;</span><span \
style="line-height: 23.8px;">detectClipboardUrl&nbsp;</span><span style="line-height: 1.7;">of \
QClipboard::dataChanged() was called twice&nbsp;</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>&nbsp; &nbsp; def __init__(self, \
parent=None):</div><div>&nbsp; &nbsp; &nbsp; &nbsp; super().__init__(parent)</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; self.clipboard = QApplication.clipboard()</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp; self.clipboard.dataChanged.connect(self.detectClipboardUrl) \
&nbsp;</div><div><br></div><div>&nbsp; &nbsp; @pyqtSlot()</div><div>&nbsp; &nbsp; def \
detectClipboardUrl(self):</div><div>&nbsp; &nbsp; <span class="Apple-tab-span" \
style="white-space:pre">	</span>print('detectClipboardUrl')</div><div>&nbsp; &nbsp; <span \
class="Apple-tab-span" style="white-space:pre">	</span>clipboardText = \
self.clipboard.text()</div><div>&nbsp; &nbsp; <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>&nbsp; &nbsp; app = QApplication(sys.argv)</div><div>&nbsp; \
&nbsp; ui = MainWindow()</div><div>&nbsp; &nbsp; ui.show()</div><div>&nbsp; &nbsp; \
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>&nbsp;</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