Hey all

I am trying to create a treeview in which the parent holds different information than its children, so i created two seperate classes, postheaderitem and postdataitem, for this and one abstract class, abstractpostitem, which also serves as a rootitem.

From a dialog I create an entire new tree item with its child items and return that. That item I want to append to my rootitem. Before I append it I want to set the parent of the new item so it points to rootItem.

Qt Code:
  1. void PostModel::addPost(AbstractPostItem newPost)
  2. {
  3. newPost.setParent(rootPost);
  4. this->insertRows(rootPost->childCount(),1,newPost,QModelIndex());
  5. }
To copy to clipboard, switch view to plain text mode 

The type created in my dialog is of postheaderitem and that is passed to this function as newPost. But the setParent function is called in the abstractpostitem and not in the postheaderitem.

So I am wondering if I should cast newPost to a postheaderitem or if I am doing something else wrong.

Regards
eekhoorn12