[Qt-interest] Why does "Qstr = doc.toString();" crash?

Knapp magick.crow at gmail.com
Tue Mar 10 23:37:54 CET 2009


Any ideas what I did wrong or how to go about fixing it? When the line
is commented out it all works fine but with it in I get:

Starting /home/douglas/download/GURPS/4th Ed./charPro/TryTwo/TryTwo...
The program has unexpectedly finished.
/home/douglas/download/GURPS/4th Ed./charPro/TryTwo/TryTwo exited with code 0

When that method is called.

void MainWindow::loadXML()
{
    QString qStr;
    QDomDocument doc( "AdBookML" );
    QFile file( ":/Pictures/Library__L.glb" );
    if( !file.open(QFile::ReadOnly | QFile::Text)) errorReport(tr("XML
Open file error!"));
    if( !doc.setContent( &file ))
    {
      file.close();
      errorReport(tr("XML SetContents error!"));
    }


    qStr = doc.toString();


    file.close();

     QDomElement docElem = doc.documentElement();
     QDomNode n = docElem.firstChild();
     while(!n.isNull()) {
         QDomElement e = n.toElement(); // try to convert the node to
an element.
         if(!e.isNull()) {
             cout << qPrintable(e.tagName()) << endl; // the node
really is an element.
         }
         n = n.nextSibling();
     }
}

-- 
Douglas E Knapp



More information about the Qt-interest-old mailing list