2

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" ')
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Sherafati
  • 196
  • 1
  • 10

1 Answers1

2

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()
eyllanesc
  • 235,170
  • 19
  • 170
  • 241