How to emit signal with same SLOT



  • I have the followiing connection: (pyqt)
    ######################################
    QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL("textChanged()"),
    lambda: self.materialsInstance.setFilterDict_Insert("L",self,"name",unicode(self.lineEdit.text())))
    #######################################

    It works fine.

    I wrote a Form validator, in another class, When i send empty QLinEdit, my validator chack it and want to user again input data, but my connection doesn't work again.

    My question is :
    How i emit the given signal with is invoked Slot that i wrote? or Do you have better solution?



  • Hi, Think you have three options IYAM.
    The first, set the validator on the LineEdit itself. This way the signal will never be empty when sending. You never know who will all be listening to the signal, so when an empty string is not valid, do not send the signal
    Second: When an empty string is detected, signal this to the emitter of the signal (new signal/slot connection) and when user inserts new data reemit the signal (normal execution)
    Third: Do a recursive call to your slot (highly discouraged IYAM)
    Greetz



  • I'm newbie , can you write me hwo to emit signal ?



  • euh,
    emit signalname;

    and define the signal in your class:
    @signals:
    signalname();@
    When you need arguments in the signal, simply add and also in the emit add them.
    There is a good tutorial howto with signal/slots:
    "Signals&Slots":http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.