user2339945
user2339945

Reputation: 673

PyQt4 connect to signal "textValueChanged()"

I have a app that uses PyQt4 for GUI. But having some issues with connecting to signals.

I made a button like this

    self.button=QtGui.QPushButton("Load File") 
    QObject.connect( self.button,   SIGNAL('clicked ()'),     self.clicked )

And it perfectly fires the following function:

def clicked(self):

So in the same manner i made a input element. However the input element signal does not fire when i change the text.

    self.filter=QtGui.QInputDialog() #Create the Input Dialog
    self.filter.setInputMode (self.filter.InputMode.TextInput ) #Change the input type to text
    self.filter.setOption(self.filter.InputDialogOption.NoButtons,True) #I don't need the buttons so i have removed them
    self.filter.setLabelText("Filter") #I change the label to "filter"
    self.connect(  self.filter,   QtCore.SIGNAL("textValueChanged()"),     self.filterUpdate ) #I connect to the signal textValueChanged() that should be fired when the text is changed and make it fire the filterUpdate() function

The following is never fired:

def filterUpdate(self):
    print "Hello"

Upvotes: 1

Views: 284

Answers (1)

warvariuc
warvariuc

Reputation: 59604

This works here:

from PyQt4 import QtCore, QtGui

import sys

app = QtGui.QApplication(sys.argv)

def filterUpdate():
    print('!')

filter = QtGui.QInputDialog()
filter.setInputMode (filter.TextInput)
filter.setOption(filter.NoButtons, True)
filter.setLabelText("Filter")
filter.textValueChanged.connect(filterUpdate)

filter.show()

sys.exit(app.exec_())

Upvotes: 1

Related Questions