Reputation: 216
I'm trying to assign a signal to a pushbutton so that it calls a function which filters and shows specific data on tableView. but when i click on the button it says:
Type error: setFilter(self, str) too many arguments
and the application crashes
assigning signal
self.ui.pushButton.clicked.connect(lambda : self.search(self.ui.lineEdit.text()))
def search(self,item):
item = "%" + item + "%"
self.model.setFilter('name LIKE ?',(item,))
self.model.select()
but when there are no other parameters but self
in search()
it works
self.model.setFilter('name LIKE "John" ')
Upvotes: 2
Views: 212
Reputation: 244212
setFilter() does not accept placeholders so you just have to concatenate:
def search(self,item):
self.model.setFilter("name LIKE '%{}%'".format(item))
self.model.select()
Upvotes: 2