hab mein problem leider noch immer nicht lösen können
also in meiner mainwindow.h hab ich folgendes deklariert:
Code: Alles auswählen
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindow( QWidget * parent = 0, Qt::WFlags f = 0 );
void setInsert(QString title);
private slots:
//irgendwas
signals:
//irgendwas
protected:
//irgendwas
private:
QString cXmlTitle;
};
#endif
in mainwindow.cpp steht folgendes:
Code: Alles auswählen
MainWindow::MainWindow( QWidget * parent, Qt::WFlags f) : QMainWindow(parent, f) //Standardconstructor
{
setupUi(this); //MainWindow set aktiv
setupActions(); //connect signals and slots
activateManual(); //activate manusl control for default
//Initialize all variables
nCountkoor=0;
nCountsave=0;
nCountin=0;
cXmlTitle="Route 1";
cXmlDescription="Testfile";
cXmlAuthor="Rainer";
mFilePath = "out.xml";
}
void MainWindow::setInsert(QString title)
{
cXmlTitle = title;
}
in der datei xml.h ist folgendesn:
Code: Alles auswählen
#ifndef __XML_H__
#define __XML_H__
#include "ui_xml.h"
class MainWindow;
class XmlDialog : public QDialog, public Ui::xmlDialog
{
Q_OBJECT
public:
XmlDialog( QWidget * parent);
protected:
//irgendwas
private slots:
void insert();
private:
MainWindow *mainWindow;
QString cTitle;
QString cDescription;
QString cAuthor;
};
#endif // __XML_H__
und in der datei xml.cpp steht folgender Code
Code: Alles auswählen
#include "xml.h"
#include <QtGui>
#include "mainwindow.h"
XmlDialog::XmlDialog(QWidget *parent): QDialog(parent)
{
setupUi(this);
mainWindow = new MainWindow(this);
setupActions();
}
void MainWindow::xmlWindow()
{
XmlDialog preview(this);
preview.exec();
}
void XmlDialog::setupActions()
{
//irgendwas..
connect(commitButton, SIGNAL(clicked()), this, SLOT(insert()));
}
void XmlDialog::insert()
{
cout << "Title: " << qPrintable(cTitle) << endl;
mainWindow->setInsert(cTitle);
}
in der datei mainwindow.cpp möchte ich dann wiederrum diese werte in einem xml file speichern:
Code: Alles auswählen
void MainWindow::saveFile(const QString &name)
{
QFile o_file(name);
if (o_file.open(QIODevice::WriteOnly)==0) //open device for writing
{
statusBar()->showMessage(tr("File not saved."), 3000);
}
else
{
statusBar()->showMessage(tr("File saved."), 3000);
}
QDate datetest(QDate::currentDate()); //Datum zuständig
QString datumvalue=datetest.toString ("dd.MM.yyyy");//DATUM
QDomElement route = s_xmldoc.createElement("Route");
QDomElement routeinfo = s_xmldoc.createElement("RouteInfo");
QDomElement title = s_xmldoc.createElement("Title");
QDomText name1 = s_xmldoc.createTextNode(cXmlTitle);
QDomElement item = s_xmldoc.createElement("Beschreibung");
QDomText filename = s_xmldoc.createTextNode(cXmlDescription);
QDomElement date = s_xmldoc.createElement("Datum");
QDomText huu = s_xmldoc.createTextNode(datumvalue);
QDomElement autor = s_xmldoc.createElement("Autor");
QDomText autorname = s_xmldoc.createTextNode(cXmlAuthor);
QDomElement routedaten = s_xmldoc.createElement("RouteDaten");
s_xmldoc.appendChild(route);
route.appendChild(routeinfo);
routeinfo.appendChild(title);
title.appendChild(name1);
routeinfo.appendChild(item);
item.appendChild(filename);
routeinfo.appendChild(date);
date.appendChild(huu);
routeinfo.appendChild(autor);
autor.appendChild(autorname);
route.appendChild(routedaten);
routedaten.appendChild(koordinaten);
QTextStream out(&o_file);
const int Indent=4;
s_xmldoc.save(out, Indent);
o_file.close();
}
wenn ich jetzt mein xml file speichere stehen nicht meine eingegebenen werte von xml.cpp drinnen sondern die default werte ("Route 1", "Testfile",...)
was mach ich falsch??
danke