Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    PyQt slot return value

    Language Bindings
    3
    3
    8520
    Loading More Posts
    • 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.
    • D
      deleted1 last edited by

      Any help with this would be appreciated, including hints on how to debug further.

      The pyqtSlot decorator takes a result as one of the parameters. However, I'm lost as to how to use it. Here's code to replicate my minimal problem.

      @
      import sys

      from PyQt5.QtWidgets import QApplication
      from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject

      class TestSlot( QObject ):

      newTrigger = pyqtSignal()
      
      def __init__( self ):
          super( TestSlot, self ).__init__()
      
      def doIt( self ):
          print "Call: doIt"
          test = self.newTrigger.emit()
          print "emit return val: %s" % test
      
      @pyqtSlot( result = str )
      def myTestFunction( self ):
          print "Call: myTestFunction"
          result = "Here's a return value"
          return "Even returning a string"
      

      app = QApplication( sys.argv )

      w = TestSlot()
      w.newTrigger.connect( w.myTestFunction )

      the_return_val = w.doIt()
      print "Doit return value: %s" % the_return_val
      @

      The results from this are:
      @➜ python testme.py
      Call: doIt
      Call: myTestFunction
      emit return val: None
      Doit return value: None
      @

      Where is my return value?

      1 Reply Last reply Reply Quote 0
      • R
        redstoneleo last edited by

        see more "here":http://pyqt.sourceforge.net/Docs/PyQt4/new_style_signals_slots.html

        1 Reply Last reply Reply Quote 0
        • M
          Marc243 last edited by

          @pyqtSlot( result = str ) is only for the C++ declaration.
          you can not use the return value with an emit Event. ;-(

          see http://stackoverflow.com/questions/11272951/pyqt4-pyqtslot-what-is-the-result-kwarg-for

          1 Reply Last reply Reply Quote 0
          • First post
            Last post