I have changed my code some to make use of pointers, the previous problem is solved but I still have a problem.
I will try to explain the situation some more.
I have a treeview which I would like to populate. It is going to be a treeview with a headerbar en below that one level that describes a certain group with its own information and it has child items to have some other information.
To create this I tried to make one abstract class named AbstractPostItem, this class als functions as the root item of the treeview.
For the description items in the treeview I created PostHeaderItem which inherits AbstractPostItem and for the child items of PostHeaderItem I created PostDataItem which also inherits AbstractPostItem.
Now from a dialog I try to create a new PostHeaderItem with its children, for that I use the following code:
{
{
PostDataItem *newItem = new PostDataItem(i);
newItem->setSubject(subject);
newItem->setGroup(group);
newItem->setParent(this);
addItem(newItem);
}
setSubject(subject);
setGroup(group);
}
PostHeaderItem::PostHeaderItem(QStringList files, QString subject, QString group)
{
foreach(QString i, files)
{
PostDataItem *newItem = new PostDataItem(i);
newItem->setSubject(subject);
newItem->setGroup(group);
newItem->setParent(this);
addItem(newItem);
}
setSubject(subject);
setGroup(group);
}
To copy to clipboard, switch view to plain text mode
Which is called from:
AbstractPostItem *NewPost::getPost()
{
PostHeaderItem *newItem = new PostHeaderItem(files, ui->inputSubject->text(), ui->inputUsenetGroup->text());
return newItem;
}
AbstractPostItem *NewPost::getPost()
{
PostHeaderItem *newItem = new PostHeaderItem(files, ui->inputSubject->text(), ui->inputUsenetGroup->text());
return newItem;
}
To copy to clipboard, switch view to plain text mode
Which is called from:
void PostView::newPost()
{
AbstractPostItem *tmpAbstractPostItem;
postScreen = new NewPost(this);
postScreen->setWindowFlags(Qt::Window);
postScreen->setAttribute(Qt::WA_ShowModal);
if(postScreen
->exec
() == QDialog::Accepted) {
tmpAbstractPostItem = postScreen->getPost();
postsList->addPost(tmpAbstractPostItem);
postScreen->close();
}
}
void PostView::newPost()
{
AbstractPostItem *tmpAbstractPostItem;
postScreen = new NewPost(this);
postScreen->setWindowFlags(Qt::Window);
postScreen->setAttribute(Qt::WA_ShowModal);
if(postScreen->exec() == QDialog::Accepted)
{
tmpAbstractPostItem = postScreen->getPost();
postsList->addPost(tmpAbstractPostItem);
postScreen->close();
}
}
To copy to clipboard, switch view to plain text mode
Now my problem is that in the first and second code bit everything works just as expected, but when I try to call functions from tmpAbstractPostItem in the third code bit it uses the functions in the AbstractPostItem class instead of the PostHeaderItem class which is what I want.
So my question is how can I accomplish this?
Update:
Added the files as attachment.
Bookmarks