SombreroMickey
24th February 2015, 11:20
Hi guys,
lḿ writing few rows of code to edit XML like this:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<fam_number>123</fam_number>
</data>
So i google it, then l tought that, this should write xml (loaded by qresource):
QDomDocument doc;
QDomElement xmlroot= doc.createElement ("data");
doc.appendChild (xmlroot);
QStandardItemModel *model = new QStandardItemModel(0,0);
QStandardItem *root = model->item (0,0);
QStandardItem *fam = root->child (0,0); // Here Segmantation FAULT
fam->setText (family_number);
QFile file(":/data.xml");
if(!file.open (QIODevice::WriteOnly | QIODevice::Text)) // Here FAILED to open
qDebug () << "Fail";
QTextStream stream(&file);
stream << doc.toString ();
file.close ();
But l get SEG FAILED and FAILED to open.
Can you please help me ? Thanks
lḿ writing few rows of code to edit XML like this:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<fam_number>123</fam_number>
</data>
So i google it, then l tought that, this should write xml (loaded by qresource):
QDomDocument doc;
QDomElement xmlroot= doc.createElement ("data");
doc.appendChild (xmlroot);
QStandardItemModel *model = new QStandardItemModel(0,0);
QStandardItem *root = model->item (0,0);
QStandardItem *fam = root->child (0,0); // Here Segmantation FAULT
fam->setText (family_number);
QFile file(":/data.xml");
if(!file.open (QIODevice::WriteOnly | QIODevice::Text)) // Here FAILED to open
qDebug () << "Fail";
QTextStream stream(&file);
stream << doc.toString ();
file.close ();
But l get SEG FAILED and FAILED to open.
Can you please help me ? Thanks