Setting up the contents of treewidget in a slot of a subclass of treewidget not work!
Dear All,
Yet another novice question :)
I have a subclass of QTreeWidget, called, QFileBrowser.
Code:
{
Q_OBJECT
public:
~QFileBrowser();
public slots:
void onFileModeToggled(bool);
private:
}
And in the main window, I have implemented a signal that is connected to the slot, onFilesFoldersSelected.
Everything works fine and whenever, i am emitting a signal, I land in the slot. I also see that the pointers point to the data passed in the main window. However, when I try to set the tree as in below, I could see nothing ..
Code:
QList<QTreeWidgetItem *> itemList;
itemList.append(&treeItem);
this->insertTopLevelItems(0, itemList); // I Expected this to do the job of inserting items in the tree
for (int i=0; i<strList->size(); i++)
qDebug() << strList->at(i); // I can see that the strList has the strings that I am passing !!!
I am sure, im overlooking something small. Could anyone point me to that please !!!
Thanks !!
P.
Re: Setting up the contents of treewidget in a slot of a subclass of treewidget not w
You have to create treeItem on the heap otherwise it will be destroyed after your slot finished. This is the reason you can't see anything!
Re: Setting up the contents of treewidget in a slot of a subclass of treewidget not w
Hi ..
Thank you for your reply .. It works now ..
I was expecting that some object was being destroyed but was only looking at the treewidget object. Trying to make sure it was not not destroyed but never realized that the item objects are qually important !!
Thanks again !!
P.