有一个问题,就是当我不断的双击使用自定义委托的那个单元格时,内存会不断增长,有没有办法是所有的使用这个委托的单元格都用同一个对象,而不是在createEditor函数中每次都动态生成一个对象。代码如下:
QWidget *ParameterDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == parametercolumn) {
TreeComboBox * argument_combobox = new TreeComboBox(parent);
connect(argument_combobox, SIGNAL(highlighted(QString)),
this, SLOT(commitAndCloseEditor()));
return argument_combobox;
}
else
{
return QItemDelegate::createEditor(parent, option, index);
}
}
TreeComboBox 是一个自定义的QComboBox子类,这样每次双击使用委托那一列时,都要新建new一个 这样的QComboBox导致内存不断增长,应该怎样解决呢?