cannot get clipboard text using QClipboard on Android when App in background

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

cannot get clipboard text using QClipboard on Android when App in background

iMath

I am using the following code to retrieve clipboard text once clipboard data changed on Android 

from PyQt5.QtCore import *from PyQt5.QtGui import *from PyQt5.QtWidgets import *class EngkuDict(QLabel):
    # Permissions QFile::permissions() const

    def __init__(self, parent=None):
        super().__init__(parent)
        self.showMaximized()

        self.clipboard = QGuiApplication.clipboard()
        self.clipboard.dataChanged.connect(self.clipboardTextChanged)
        # self.clipboard.changed.connect(self.clipboardModeChanged)

    @pyqtSlot()
    def clipboardTextChanged(self):
        selectedText = self.clipboard.text()
        self.setText('clipboardTextChanged: {}'.format(selectedText))

    def clipboardModeChanged(self, mode):

        selectedText = self.clipboard.text()
        self.setText('mode: {}\n{}'.format(mode, selectedText))if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    # QApplication.setQuitOnLastWindowClosed(False)

    trayIcon = EngkuDict()
    trayIcon.show()
    sys.exit(app.exec_())

when the code is running in background, I copied text in another application, this application just cannot get clipboard text, so how to solve the issue ?






 


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt