Hi. I need to save this table:
in a XML file, which will look like this:
<?xml version="1.0" encoding="UTF-8"?>
<UIS_CONFIG>
<CONFIG>
<NR_OF_UIS>1</NR_OF_UIS>
</CONFIG>
<DIGIO>
<IO>
<PIN>PINName 1</PIN>
<VAL>Angeschlossene Taste 1</VAL>
</IO>
<IO>
<PIN>PINName 2</PIN>
<VAL>Angeschlossene Taste 2</VAL>
</IO>
<IO>
<PIN>PINName 3</PIN>
<VAL>Angeschlossene Taste 3</VAL>
</IO>
<IO>
<PIN>PINName 4</PIN>
<VAL>Angeschlossene Taste 4</VAL>
</IO>
</DIGIO>
</UIS_CONFIG>
Here’s my code:
void MainWindow::on_actionExport_triggered()
{
QString filename = QFileDialog::getSaveFileName(
this,
tr("Konfig speichern"),
QDir::currentPath(),
tr("Konfigurationsdatei (*.xml)") );
if( !filename.isNull()){
QFile::remove(filename);
QFile file(filename + ".xml");
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream outPut(&file);
outPut << "Test";
}
}
You see, it just writes an XML file at a optional location with the content “Test”. I really have got not plan how to put the table as a XML file. Help please?
↧