[PyQt] pyqtsignal() and None value

J Barchan jnbarchan at gmail.com
Tue Sep 4 17:16:59 BST 2018


PyQt5.7.  I am having trouble `emit()`ing a signal and receiving its
arguments correctly.  I have read
http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html carefully.

*Declaration*:

    # class variable for "notifyProgress" signal, for displaying a
progressbar
    notifyProgress = QtCore.pyqtSignal(int, str)

*Initialisation*:

self.notifyProgress.connect(self.updateProgress)

*Slot*:

    def updateProgress(self, val: int, text: str):
        # slot for self.notifyProgress
        # eprpayrequestfunctions.runEpr() calls this to indicate progress
        # if it passes an integer it's the desired value for the progressbar
        # if it passes a string it's the desired value for the label
        if val is not None:
            self.progressBar.pb.setValue(val)
        if text is not None:
            self.progressBar.label.setText(text)

*Signals*:

1. notifyProgress.emit(None, "Some text")

2. notifyProgress.emit(i / 2, None)

*Behaviour in slot*:

The problem is the passing of None from emit():

1. val arrives in slot as 1261196128.

2. text arrives in slot as '' (empty string).

*Questions*:

   - Where is this behaviour for None as an emit() parameter documented?
   - What is the correct/best way for handling this correctly/easily?


-- 
Kindest,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180904/4cd0a619/attachment.html>


More information about the PyQt mailing list