[Interest] I feel stupid: QStandardItem::insertRows: Ignoring duplicate insertion of item

Frank Rueter | OHUfx frank at ohufx.com
Wed Apr 26 11:24:24 CEST 2017

I found the culprit but not a solution yet:
When generating the list of items in my pre-process, I already parent 
them to each other for use in a QTreeView, e.g.:
     cur_root_item.setChild(item_counter, cur_file_item)

Turns out I can't just show all items in a simple list ignoring their 
How would I go about this then if I need both a "flat" list for a report 
print out and also tree view for the user to interact with, e.g.:

QListView would show (ignoring existing parenting):

  * itemA
  * itemB
  * itemC

QTreeView of the same model would show (based on previous parenting):

Do I need two models and communicate between them (e.g. if a user 
renames an item)?
Or can this be achieved with a single model?


On 26/04/17 7:50 PM, Frank Rueter | OHUfx wrote:
> Hi,
> I seem to run into this issue a lot and I don't get why:
> I have a list of sub-classed QStandardItems that another processor 
> generated, and I want to add them to a QStandardItemModel like this:
> for item in myItemList:
>     self.model.appendRow(item)
> The model is empty and hasn't been used at this point. Yet I get none 
> of my items but one of those errors for each item:
>     QStandardItem::insertRows: Ignoring duplicate insertion of item
> I know I should know this but I can't figure out why this is 
> happening. Is there something special I need to do when subclassing 
> QStandardItem?
> Cheers,
> frank
> -- 
> <http://www.nukepedia.com> 		
> over 1,000 free tools for Nuke <http://www.nukepedia.com>
> <https://vimeo.com/channels/nukepedia/165747936> 		
> full access from within... coming soon 
> <https://vimeo.com/channels/nukepedia/165747936>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170426/8f3112f7/attachment.html>

More information about the Interest mailing list