In this example, we will learn how to write data to an XML file using the QDomDocument class. We will continue from the previous example and just add more code to it.
Writing XML data using the QDomDocument class
How to do it...
To learn how to save data into an XML file using the QDomDocument class, let's do the following:
- Add the second button to the UI, called Save XML:
- Right-click on the Save XML button and select Go to slot…. Then, pick the clicked() option and click OK. A new clicked() slot function will be added to your source files.
- Write the following code within the button's clicked() slot function:
void MainWindow::on_saveXmlButton_clicked() {
QString filename = QFileDialog::getSaveFileName...