0

Is there any efficient way to add a batch of QStandardItems to a model? The model is being cleared and then I'm adding a lot of items. QtreeWidget has addTopLevelItems ( const QList<QTreeWidgetItem *> & items ) for just this, how to optimize such addition with model / view architecture?

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • [`QStandardItemModel::appendColumn(const QList & items)`](http://qt-project.org/doc/qt-5.0/qtgui/qstandarditemmodel.html#appendColumn). Is that what you were looking for? – thuga Oct 31 '13 at 09:43
  • @thuga: possibly, I'll give it a try. But what if I have many columns, too? Then it would still be inefficient. – Violet Giraffe Oct 31 '13 at 09:47
  • Then use [`QStandardItemModel::appendRow(const QList & items)`](http://qt-project.org/doc/qt-5.0/qtgui/qstandarditemmodel.html#appendRow)? – thuga Oct 31 '13 at 09:50
  • @thuga: what if I have a large number of rows AND columns? – Violet Giraffe Oct 31 '13 at 09:52
  • This depends a lot of your `QStandardItem`s. You can add rows/columns to them. Just like in `QTreeWidgetItem` you add columns to it, not to the `QTreeWidget` itself. – thuga Oct 31 '13 at 09:54
  • @thuga: that didn't occur to me, I should try it as well. Thanks! – Violet Giraffe Oct 31 '13 at 10:09
  • If you care about efficiency, you'd better create your own model class. – Pavel Strakhov Oct 31 '13 at 13:15
  • @PavelStrakhov: oh, I've tried to. Wasted a week trying to make it work.There's too many things about model / view system that I don't understand. – Violet Giraffe Oct 31 '13 at 13:18

0 Answers0