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. PyQt slot return value
QtWS25 Last Chance

PyQt slot return value

Scheduled Pinned Locked Moved Language Bindings
3 Posts 3 Posters 9.5k Views
  • 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 Offline
    D Offline
    deleted1
    wrote on last edited by
    #1

    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
    0
    • R Offline
      R Offline
      redstoneleo
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marc243
        wrote on last edited by
        #3

        @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
        0

        • Login

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