Hi MDeath.
It works fine now.
But now Im stuck with the QList<Formula> serialization. My code:
QDataStream & operator<<
(QDataStream
& stream,
const Formulas
& formula
);
QDataStream & operator>>
(QDataStream
& stream, Formulas
& formula
);
QDataStream & operator<<
(QDataStream
& stream,
const QList<Formulas>
& list_formula
);
QDataStream & operator>>
(QDataStream
& stream,
const QList<Formulas>
& list_formula
);
QDataStream & operator<< (QDataStream& stream, const Formulas& formula);
QDataStream & operator>> (QDataStream& stream, Formulas& formula);
QDataStream & operator<< (QDataStream& stream, const QList<Formulas>& list_formula);
QDataStream & operator>> (QDataStream& stream, const QList<Formulas>& list_formula);
To copy to clipboard, switch view to plain text mode
QDataStream & operator<<
(QDataStream
& stream,
const Formulas
& formula
) {
stream<<formula.m_formula;
stream<<formula.m_values;
stream<<formula.m_variables;
return stream;
}
QDataStream & operator>>
(QDataStream
& stream, Formulas
& formula
) {
stream>>formula.m_formula;
stream>>formula.m_values;
stream>>formula.m_variables;
return stream;
}
QDataStream & operator<<
(QDataStream
& stream, QList<Formulas>
& list_formula
) {
stream<<list_formula;
return stream;
}
QDataStream & operator>>
(QDataStream
& stream, QList<Formulas>
& list_formula
) {
stream>>list_formula;
return stream;
}
QDataStream & operator<< (QDataStream& stream, const Formulas& formula)
{
stream<<formula.m_formula;
stream<<formula.m_values;
stream<<formula.m_variables;
return stream;
}
QDataStream & operator>> (QDataStream& stream, Formulas& formula)
{
stream>>formula.m_formula;
stream>>formula.m_values;
stream>>formula.m_variables;
return stream;
}
QDataStream & operator<< (QDataStream& stream, QList<Formulas>& list_formula)
{
stream<<list_formula;
return stream;
}
QDataStream & operator>> (QDataStream& stream, QList<Formulas>& list_formula)
{
stream>>list_formula;
return stream;
}
To copy to clipboard, switch view to plain text mode
reading the file
//QDataStream in(&file,&form_teste); // read the data serialized from the file
//in>>form_teste;
in>>lista_formulas;
file.close();
QFile file("file.dat");
file.open(QIODevice::ReadOnly);
//QDataStream in(&file,&form_teste); // read the data serialized from the file
QDataStream in(&file);
//in>>form_teste;
in>>lista_formulas;
file.close();
To copy to clipboard, switch view to plain text mode
writting the file
QDataStream out
(&file
);
// we will serialize the data into the file //out << form_teste;
out<<lista_formulas;
file.close();
QFile file("file.dat");
file.open(QIODevice::WriteOnly);
QDataStream out(&file); // we will serialize the data into the file
//out << form_teste;
out<<lista_formulas;
file.close();
To copy to clipboard, switch view to plain text mode
the error:
D:/qt4examples/Matematica/./debug/formulas_dlg.o:-1: error: In function `ZN12formulas_dlg21on_buttonBox_acceptedEv':
D:/qt4examples/Matematica/formulas_dlg.cpp:58: undefined reference to `operator<<(QDataStream&, QList<Formulas> const&)'
D:/qt4examples/Matematica/./debug/formulas_dlg.o:-1: error: In function `ZN12formulas_dlg21on_buttonBox_acceptedEv':
D:/qt4examples/Matematica/formulas_dlg.cpp:58: undefined reference to `operator<<(QDataStream&, QList<Formulas> const&)'
To copy to clipboard, switch view to plain text mode
if I put a comment in the lines
in>>lista_formulas;
out<<lista_formulas;
in>>lista_formulas;
out<<lista_formulas;
To copy to clipboard, switch view to plain text mode
it compiles and run fine
Bookmarks