Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何替换Qt模型视图框架中的子对象?_C++_Qt_Model View - Fatal编程技术网

C++ 如何替换Qt模型视图框架中的子对象?

C++ 如何替换Qt模型视图框架中的子对象?,c++,qt,model-view,C++,Qt,Model View,我正在使用qabstractemmodel来实现我的模型。我有一个父项,希望用另一组子项替换其子项。在替换之前和之后,我应该使用什么模型方法?或者我应该发出什么模型信号?谢谢。在模型中,父项是父项的QModelIndex,计数是要添加的子项的数量: beginRemoveRows(parent, 0, rowCount(parent)); //remove from data endRemoveRows(); beginInsertRows(parent, 0, count); //add ro

我正在使用
qabstractemmodel
来实现我的模型。我有一个父项,希望用另一组子项替换其子项。在替换之前和之后,我应该使用什么模型方法?或者我应该发出什么模型信号?谢谢。

在模型中,父项是父项的QModelIndex,计数是要添加的子项的数量:

beginRemoveRows(parent, 0, rowCount(parent));
//remove from data
endRemoveRows();
beginInsertRows(parent, 0, count);
//add rows into data
endInsertRows();