Results 1 to 3 of 3

Thread: children()

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default children()

    Hi,
    What should be the count of children()?? I think it should be 3. But it shows 0. Can anyone correct me...

    Qt Code:
    1. class mainObject : public QObject{
    2. public:
    3. mainObject( QObject * parent = 0 ){}
    4. ~mainObject(){}
    5. };
    6.  
    7. class myObject : public mainObject{
    8. public:
    9. myObject( QObject * parent = 0 ) : mainObject( parent ){}
    10. ~myObject(){}
    11. };
    12.  
    13. int main(int argc, char *argv[]){
    14. mainObject* ob = new mainObject;
    15. myObject* a = new myObject(ob);
    16. myObject* b = new myObject(ob);
    17. myObject* c = new myObject(ob);
    18.  
    19. qDebug() << ob->children().count();
    20. return 0;
    21. }
    To copy to clipboard, switch view to plain text mode 

    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: children()

    Looks like you forgot to call the QObject constructor from mainObject().
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: children()

    Quote Originally Posted by Michiel View Post
    Looks like you forgot to call the QObject constructor from mainObject().
    Oh, I'm really fool....

    Thanks a lot....

Similar Threads

  1. Slow GraphicsItem->setVisible() with say 200 children
    By sheckey in forum Qt Programming
    Replies: 6
    Last Post: 10th May 2007, 00:57
  2. QTreeView and QStandardModel : add children
    By Valheru in forum Newbie
    Replies: 7
    Last Post: 19th September 2006, 17:24
  3. Replies: 1
    Last Post: 18th July 2006, 10:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.