PDA

View Full Version : children()



vermarajeev
14th May 2007, 15:09
Hi,
What should be the count of children()?? I think it should be 3. But it shows 0. Can anyone correct me...


class mainObject : public QObject{
public:
mainObject( QObject * parent = 0 ){}
~mainObject(){}
};

class myObject : public mainObject{
public:
myObject( QObject * parent = 0 ) : mainObject( parent ){}
~myObject(){}
};

int main(int argc, char *argv[]){
mainObject* ob = new mainObject;
myObject* a = new myObject(ob);
myObject* b = new myObject(ob);
myObject* c = new myObject(ob);

qDebug() << ob->children().count();
return 0;
}

Thanks

Michiel
14th May 2007, 15:12
Looks like you forgot to call the QObject constructor from mainObject().

vermarajeev
14th May 2007, 15:15
Looks like you forgot to call the QObject constructor from mainObject().

Oh, I'm really fool....:p

Thanks a lot....