I wrote a function
void Module::reset()
The value of model in Listview is reset inside. And it did change, but it did not change immediately on the Listview display
The function at the beginning is written like this
void Module::reset(){
for(unsigned int i=0;i<module_.size();i++){
QModelIndex start_index = createIndex(i, 0);
setData(start_index,module_[i]->default_value_.data(),1);
}
}
There is a change but there is no immediate response, the correct value will be displayed only after receiving the switch
Two lines of code were added afterwards:
void Module::reset(){
beginResetModel();
for(unsigned int i=0;i<module_.size();i++){
QModelIndex start_index = createIndex(i, 0);
setData(start_index,module_[i]->default_value_.data(),1);
}
endResetModel();
}
It turns out that to operate on data, you must write the corresponding begin and end. Listview will change dynamically.
There are several types: