Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDomNode.setContent() doesn't work...
Forum Updated to NodeBB v4.3 + New Features

QDomNode.setContent() doesn't work...

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    Hello
    I'm trying the following:

    @QDomDocument configDoc;
    QFile storage("c:/Time/data.xml");
    if(!storage.open(QIODevice::ReadOnly))
    {
        qDebug("ERROR opening file");
    }
    if( !configDoc.setContent( &storage ) )
    {
        qDebug("ERROR settings content");
    }
    storage.close();@
    

    Where the file contains e.g.:

    @<?xml version="1.0"?>
    <config version="0.1">
    <id>123</id>
    <hwVersion>2</hwVersion>
    </config>@

    But it always fails to set the content (setContent() -> false) I've include

    #include <QFile>
    #include <QtXml>

    and added xml to the pro file but nothing seems to work. Could this be platform related? I have
    the same code in use on a linux platform based solution and there it works fine, but can't manage to get
    it to work on windows.. (just to clarify, it's not the same code, so there might be defferences I ahven't noticed,
    but this function is copy/pasted)

    Br.
    Richard

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      You could try appending QIODevice::Text to your open mode flags; you might be running into line ending issues on Windows.

      Another option would be passing the optional parameters to setContent() required for reading the parse error and taking a look at it.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved