Results 1 to 2 of 2

Thread: implement 'nextSibling()' method

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default implement 'nextSibling()' method

    Hello,
    I'd like to obtain this under but I don't know what I must to use. I need to access to the father of an object; I give you the idea under here:
    Qt Code:
    1. public class MyElemNode extends MyNode {
    2. List<MyNode> child = new ArrayList<MyNode>();
    3.  
    4. public MyElemNode() { }
    5. public MyNode getFirstChild() { return child.get(0); }
    6. public MyNode getLastChild() { return child.get( child.size()-1 ); }
    7. public MyNode nextSiblingNode() { //1
    8. int i = getPositionOfThisObjectInFather.child();
    9. return father.child(i+1);
    10. }
    11. }
    12. //main
    13. MyElemNode e = new MyElemNode();
    14. e. add( new MyElemNode, new MyElemNode ......................);
    15. MyElemNode ep = e.get(5); //assuming it exists
    16. MyElemNode sib = ep.nextSibling(); // how to obtain this?
    To copy to clipboard, switch view to plain text mode 
    thanks
    Regards

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: implement 'nextSibling()' method

    Pass the parent (father) in the constructor or add a setParent() function to your node.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. How does Qt implement layers?
    By FinderCheng in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2009, 13:12
  2. QTreeWidget nextSibling()
    By user_mail07 in forum Newbie
    Replies: 1
    Last Post: 21st August 2008, 19:44
  3. how to implement this widget
    By pencilren in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2007, 11:10
  4. What's the best way to implement a MainWindow
    By darkadept in forum Qt Programming
    Replies: 5
    Last Post: 5th February 2007, 17:46
  5. how to implement it ?
    By qtopiahooo in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2006, 17:01

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.