[Qt-interest] doc to string cause "program unexpectedly finished" error

Malyushytsky, Alex alex at wai.com
Sat Mar 7 01:29:43 CET 2009


First I would make sure that this is toString() problem.
Check ui and textEdit are valid pointers. I would recoomend using Q_ASSERT at least.

Split that line in 2.

QString s = doc.toString();
ui->textEdit->setText(s);

If it is toString() problem, try to find what cause a problem. You probably can do it by editing xml file.

Sorry if it was not a lot of help.

Alex

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Knapp
Sent: Friday, March 06, 2009 7:12 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] doc to string cause "program unexpectedly finished" error

Everything seems to work until this. When I click the button that
calls this slot the program ends with "program unexpectedly finished"
error.

Problem is the line starting with ui->, all I want to do is view the
xml from the QDomDocument doc. I don't understand why this does not
work. When I comment out this like it works fine.

Hope this is not a totally newbie question but I am afraid it is.
Thanks for the help!

void MainWindow::loadXML()
{
    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!"));
    }
    ui->textEdit->setText(doc.toString());
    file.close();
}

--
Douglas E Knapp
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list