pyqt5 - QSortFilterProxyModel does not apply Caseinsensitive -


as i've subclassed qsortfiltermodel able search thru several coloumns in qlistview, caseinsensitive option no longer works. ive tried apply follows:

class customsortfilterproxymodel(qtcore.qsortfilterproxymodel):     def __init__(self, parent=none):         super(customsortfilterproxymodel, self).__init__(parent)         self.filterstring = ''         self.filterfunctions = {}          self.setfiltercasesensitivity(qtcore.qt.caseinsensitive) #applied here        def setfilterstring(self, text):          self.filterstring = str(text)         self.setfiltercasesensitivity(qtcore.qt.caseinsensitive)    #and applied here         self.invalidatefilter()      def filteracceptsrow(self, row_num, parent):          self.filtercolumns = [1,3]             model = self.sourcemodel()           row = model.row(row_num)         tests = [self.filterstring in row[col] col in self.filtercolumns]          return true in tests  

how come search string case sensitive?

the sensitivity set there applies default filteracceptsrow implementation. if override it, you'll need handle yourself, doing like:

return any(self.filterstring.casefold() in row[col].casefold() col in self.filtercolumns)) 

(see str.casefold docs)


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -