Good day. There is a problem with creating a valid loop to track value changes in a QTreewidgetItem. Actually it is necessary to realize the slot handler when you press the button, all values โ€‹โ€‹in the column (3) are scanned and saved in the ini file.

void sw_IKGM_settings::handler_pb_save_changes_to_ini() { QTreeWidgetItem* pitem; QStringList mylist; int i = 0; // sw_tree_item_my - ัั‚ั€ัƒะบั‚ัƒั€ะฐ, tc - QList ัั‚ั€ัƒะบั‚ัƒั€ foreach(sw_tree_item_t my, tc) { my = tc.at(i); QString str = my.item->text(3) str = mylist.at(i); } 

When executing, the program terminates incorrectly. I can get the last element of the sheet using the .last () function, but I need to know all the changed values โ€‹โ€‹and not one.

  • The loop is strange in me, and so the value from the list is transferred, but at each iteration you rewrite it with the value of the first element of the loop. Also, you access the first element of mylist, which is always empty. Are there any changed items in tc ? Or do they still need to be defined? - gil9red
  • In tc are all the elements that we read from the ini file and then put it on the widget. It was assumed that it was necessary to iterate through each element from the container and, by iterator, replace every fourth one with the value read from the widget when the user presses the save value button. - Tony Estakado
  • why not just save all the values? There are so many to keep everything? - gil9red
  • These are the conditions of the task, the remaining fields are not editable โ€” only one value field is being edited. Although on the whole, it could have been done to re-save the entire ini file every time, as a result, I did it - because the standard QSettings works disgustingly with special characters and [] he understood only% 5B% 5D. - Tony Estakado
  • I would not save tables and trees in ini format :) Better xml or json. Those. you just need to go through the rows of the table and compare the current values โ€‹โ€‹with the values โ€‹โ€‹from tc. And what will you do next with this?) - gil9red

0