Results 1 to 6 of 6

Thread: Can't get child of qDomNode

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,346
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Can't get child of qDomNode

    Using the same name for each child element will also make it a bit easier to traverse the hierarchy - instead of going sibling by sibling and testing for null, you can simply ask for all child nodes with a given tag name (into a QDomNodeList) and just iterate over it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Sep 2010
    Location
    Denmark
    Posts
    28
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 3 Times in 1 Post

    Default Re: Can't get child of qDomNode

    I've got it working. Right now, the beginning of the file looks like this
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <project>
    3. <info project_name="mattMathilde" project_path="C:/Users/gldalar5/mattMathilde" pad_width="800" pad_height="600"/>
    4. <storyboard padCount="2" folder="epi1">
    5. <pad timing="50">
    6. <line p1x="79" p1y="68" p2x="81" p2y="68" rgb="4293958640" width="11"/>
    7. <line p1x="81" p1y="68" p2x="83" p2y="67" rgb="4293958640" width="11"/>
    8. <line p1x="83" p1y="67" p2x="87" p2y="66" rgb="4293958640" width="11"/>
    9. <line p1x="87" p1y="66" p2x="91" p2y="64" rgb="4293958640" width="11"/>
    10. <line p1x="91" p1y="64" p2x="97" p2y="63" rgb="4293958640" width="11"/>
    To copy to clipboard, switch view to plain text mode 
    Thanks to your suggestions, the xml is much better and precise now.
    The 'padCount' value was moved from the 'project' to the 'storyboard' tag, where it belongs. A project can have many storyboards, and each storyboard must know how many pads there are to the storyboard. My mistake.
    The 'count' value in the 'pad' tag has been removed, since I don't use the count, and just iterate over lines in each pad.
    Each line has a color AND a width, so I added a 'width' value. Another mistake.
    And - finally - the idea of calling the pad-node 'pad' and the line-node 'line', is so obvious, that it almost hurts.
    Thankyou for helping!

Similar Threads

  1. QDomNode delete children
    By trallallero in forum Qt Programming
    Replies: 9
    Last Post: 11th December 2013, 01:13
  2. QDomNode replaceChild is not work
    By lucasbemo in forum Newbie
    Replies: 1
    Last Post: 6th December 2010, 18:03
  3. Problem with Deleting QDomNode
    By metdos in forum Qt Programming
    Replies: 6
    Last Post: 16th July 2010, 19:58
  4. QDomNode
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 07:11
  5. QDomNode
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2007, 13:18

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.