[Qt-interest] childCount()

Srdjan Todorovic todorovic.s at googlemail.com
Fri Jul 31 11:00:25 CEST 2009


On 31/07/2009, Sujan Dasmahapatra <sujan.dasmahapatra at gmail.com> wrote:
> Dear Friends
> After I added a child TreeWidgetItem into an existing TreeWidgetItem but the
> value of childCount() is not updated. What could be the reason can  anyone
> tell me ?
>
> *Sample*
> QTreeWidget *treeWidget = new QTreeWidget;
> QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget);
> QTreeWidgetItem *child = new QTreeWidgetItem(item);
> child->setText("I am a child");

Hmm. Can't see anything immediately wrong with this...

> item1->addChild(child);

What's item1?

> *// Afte this I am trying to access childCount() values but it's giving junk
> value*
> int n = item->childCount(); // it's not giving the value as = 1.*

Junk value? What is the value of n?

Srdjan



More information about the Qt-interest-old mailing list