Connecting signal to slot immediately causes signal to be emitted

前端 未结 3 1201
不思量自难忘°
不思量自难忘° 2021-01-24 12:34

I am writing a program with python 3.3.3 and pyqt5. I have connected many signals and slots with no problem. This one is causing a problem. My code follows:

          


        
3条回答
  •  迷失自我
    2021-01-24 13:27

    The error is caused by attempting to connect to the result of a function call (which in this case is None), instead of the function object itself. Of course, this also explains why the function is executed immedaitely.

    You should wrap the function call in a lambda, like this:

        vendorComboBox.currentTextChanged.connect(
            lambda: _vendorChanged(vendorComboBox, dictVendors, modelComboBox))
    

提交回复
热议问题