PDA

View Full Version : Slight change leads to segmentation fault in qt example



codemonkey
24th January 2010, 08:10
Hello.
I have just compiled the simpetreemodel example that comes with the qt sources. That worked fine.
But this slight change to the treemodel constructor (the last two lines with the x variable) gives me a segmentation fault. Does anyone know why? To me it is a mystery and I must have failed to understand something very basic?


TreeModel::TreeModel(const QString &data, QObject *parent)
: QAbstractItemModel(parent)
{
QList<QVariant> rootData;
rootData << "Title" << "Summary";
rootItem = new TreeItem(rootData);
setupModelData(data.split(QString("\n")), rootItem);

TreeItem* x = new TreeItem(rootData);
rootItem->appendChild(x);
}


I should add that I just wanted to try to add an extra item. But it seems that did not work.