Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qlineedit returnpressed obtain handle to it



  • I wonder if someone could help me with the following:

    I create in a loop many Qlineedit input fields and connect for each instance the returnpressed action to a function called "r_pressed"
    -> How can I obtain inside the r_pressed function, a handle to the Qlineedit that triggered it?

    for i in [1,2,3]:
        tmp = QtWidgets.QLineEdit(str(i))
        tmp.returnPressed.connect(r_pressed)
    
    def r_pressed():
       i = ? -> How do I get the value of i inside the r_pressed function? (or something equivalent, like the reference to the qlineedit instance that triggered it....)
    

    Any hints are very welcome!



  • QObject::sender()


Log in to reply