J
J
jonikwm2015-10-12 08:15:44
Python
jonikwm, 2015-10-12 08:15:44

Strange behavior of Python + PySide. How to change data recursively in QSortFilterProxyModel()?

Hello! Help me to understand.
From model = QSqlTableModel()I receive the table with some quantity of fields.
Next, I put a filter on it:

def update_list(): тут пытаюсь заменить все значения "значение_1" на "значение_2" во второй колонке
    i = 0 #счетцик
    while i < model_list.rowCount():
      model_list.setData(model_list.index(i, 2), 'значение_2') в этом моменте происходит магия. см. ниже
      print ('счетчик ',i)
      i = i+1
    print ('количество строк',model_list.rowCount())
    model.select()
    print('Обновление')



  model_list = QSortFilterProxyModel()
  model_list.setSourceModel(model)
  model_list.setFilterCaseSensitivity(Qt.CaseInsensitive)
  model_list.setFilterKeyColumn(2)
  model_list.setFilterFixedString('значение_1') 
  update_list()

The output is some kind of heresy.
Not all values ​​change, but only half in random order.
What am I doing wrong? Maybe there is another way to change the values ​​in QSortFilterProxyModel() in one go?
PS The code may contain inaccuracies since this is not the first time I've tried to make it work.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question