I'm currently trying to put the values of some QLineEdits into a XML document. I use QDom for this. Here's my code:
void MainWindow::writeSysConf(const QString &arg1){
QFileDialog fdExport;
QString filename = fdExport.getSaveFileName(
this,
tr("SysConf-Konfig speichern"),
arg1,
tr("Konfigurationsdatei (*.xml)") );
if( !filename.isNull()) {
QFile::remove(filename);
if ( !filename.endsWith(".xml", Qt::CaseInsensitive))
filename += ".xml";
QFile file(filename);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream outPut(&file);
QDomDocument xmlDocument;
QDomElement sysConfigElement = xmlDocument.createElement("SYSTEMCONFIGURATION");
QDomElement calibElement = xmlDocument.createElement("CALIB");
QDomElement crescendoElement = xmlDocument.createElement("CRESCENDO");
QDomElement swellsElement = xmlDocument.createElement("SWELLS");
sysConfigElement.appendChild(calibElement);
calibElement.appendChild(crescendoElement);
QDomNode minNode = xmlDocument.createElement(ui->lineEdit_2->text);
QDomNode maxNode = xmlDocument.createElement(ui->lineEdit_3->text);
QDomNode stepsNode = xmlDocument.createElement(ui->lineEdit_4->text);
QDomNode updateMsNode = xmlDocument.createElement(ui->lineEdit_5->text);
crescendoElement.appendChild(minNode);
crescendoElement.appendChild(maxNode);
crescendoElement.appendChild(stepsNode);
crescendoElement.appendChild(updateMsNode);
calibElement.appendChild(swellsElement);
xmlDocument.appendChild(sysConfigElement);
outPut << xmlDocument.toString(4);
}
}
But, at these four lines:
QDomNode minNode = xmlDocument.createElement(ui->lineEdit_2->text);
QDomNode maxNode = xmlDocument.createElement(ui->lineEdit_3->text);
QDomNode stepsNode = xmlDocument.createElement(ui->lineEdit_4->text);
QDomNode updateMsNode = xmlDocument.createElement(ui->lineEdit_5->text);
it says that I would try to use an unresolved, overloaded function type to put this in my QDomNodes. But, as far as I know, QLineEdits return a QString. So where's the problem?
Fixed it. You just need to add a () behind ui->lineEdit->text as it's a function. So mine would look like this in the proper way: