Results 1 to 4 of 4

Thread: Is there any example code which read and writes data from/to XML file?

  1. #1
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Question Is there any example code which read and writes data from/to XML file?

    Is there any example code which read and writes data from/to XML file?

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there any example code which read and writes data from/to XML file?

    Qt examples contains an example that reads and write xml file. I think it is called dombookmarks.

  3. #3
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there any example code which read and writes data from/to XML file?

    Quote Originally Posted by rajesh
    Is there any example code which read and writes data from/to XML file?

    Yes! just launch Qt Demo (Qt 4) and the select the bottom most option "XML"!!!

  4. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is there any example code which read and writes data from/to XML file?

    Quote Originally Posted by rajesh
    Is there any example code which read and writes data from/to XML file?
    This follow line source fill 14 qlineedit & 5 qcombobox on method:

    http://doc.trolltech.com/4.1/qobject.html#findChildren

    is the application setting file .....

    and inverse / write you can found on http://qtforum.de/forum/viewtopic.php?t=2192


    Qt Code:
    1. void Setting_Gui::ReadConfig()
    2. {
    3. QString configwget = APPLICATION_SETTING;
    4. QFile xmlfile(configwget);
    5. if(!xmlfile.open( QIODevice::ReadOnly ) ) {
    6. ErrorConfig("");
    7. }
    8. QString errorStr, obname, inhalt;
    9. int errorLine;
    10. int errorColumn;
    11.  
    12. QDomDocument doc("http://www.pulitzer.ch/2005/PuliCMS/1.0");
    13. if (!doc.setContent(&xmlfile,true, &errorStr, &errorLine, &errorColumn)) {
    14. QString error = (QString("Parse error at line %1, column %2:\n%3")
    15. .arg(errorLine)
    16. .arg(errorColumn)
    17. .arg(errorStr) );
    18. ErrorConfig(error);
    19. xmlfile.close();
    20. }
    21. QDomElement root = doc.documentElement();
    22. if( root.tagName() != "setting" ) {
    23. ErrorConfig("");
    24. }
    25. QDomNode n = root.firstChild();
    26. while( !n.isNull() )
    27. {
    28. QDomElement e = n.toElement();
    29. if( !e.isNull() )
    30. {
    31. for (int i=0;i<textList.size();i++){
    32. obname =QString(textList[i]->objectName());
    33. if( e.tagName() == obname ) {
    34. textList[i]->setText(decodeBase64(e.text()));
    35. }
    36. }
    37. for (int x=0;x<boxList.size();x++){
    38. obname =QString(boxList[x]->objectName());
    39. if( e.tagName() == obname ) {
    40. inhalt = decodeBase64(e.text());
    41. int summ = boxList[x]->count();
    42. for (int i=0;i<summ;i++){
    43. QString value = boxList[x]->itemText(i);
    44. if (inhalt == value) {
    45. boxList[x]->setCurrentIndex(i);
    46. }
    47. }
    48. }
    49. }
    50. n = n.nextSibling();
    51. }
    52. }
    53. xmlfile.close();
    54. }
    To copy to clipboard, switch view to plain text mode 

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.