Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. slot of QClipboard::dataChanged() was called twice
Forum Updated to NodeBB v4.3 + New Features

slot of QClipboard::dataChanged() was called twice

Scheduled Pinned Locked Moved Unsolved Language Bindings
1 Posts 1 Posters 683 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redstoneleo
    wrote on last edited by
    #1

    The slot detectClipboardUrl of QClipboard::dataChanged() was called twice sometimes when I copy url in Google Chrome's address bar in this code, tested with PyQt5.7,Python3.5 on Win7 32bit, also on Linux Mint 18, while I need the slot to be called only once , is this a bug ? 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_())
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved