alextavara
25th November 2009, 14:31
I want to write a QList to a file and I get this error:
c:/Qt/2009.04/qt/include/QtCore/../../src/corelib/io/qdatastream.h:252: error: no match for 'operator<<' in 's << (+l)->QList<T>::at [with T = Registro::alumData](i)'
In my registro.h I have this:
typedef struct curData{
QString Nombre;
QList <int> Notas;
int Promedio;
}cursoRegistro;
typedef struct alumData{
QString Nombre;
int Codigo;
QList <cursoRegistro> Cursos;
int Promedio;
}alumnoRegistro;
QList <alumnoRegistro> Alumnos;
My function to save the file (in registro.cpp) is:
void Registro::guardarArchivo()
{
QString nombreArchivo = QFileDialog::getSaveFileName(this);
if (nombreArchivo.isEmpty()) {
return;
}
QFile file(nombreArchivo);
if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("No se puede abrir archivo"), file.errorString());
return;
}
QDataStream out(&file);
out << Alumnos;
}
I'm a beginner.
c:/Qt/2009.04/qt/include/QtCore/../../src/corelib/io/qdatastream.h:252: error: no match for 'operator<<' in 's << (+l)->QList<T>::at [with T = Registro::alumData](i)'
In my registro.h I have this:
typedef struct curData{
QString Nombre;
QList <int> Notas;
int Promedio;
}cursoRegistro;
typedef struct alumData{
QString Nombre;
int Codigo;
QList <cursoRegistro> Cursos;
int Promedio;
}alumnoRegistro;
QList <alumnoRegistro> Alumnos;
My function to save the file (in registro.cpp) is:
void Registro::guardarArchivo()
{
QString nombreArchivo = QFileDialog::getSaveFileName(this);
if (nombreArchivo.isEmpty()) {
return;
}
QFile file(nombreArchivo);
if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("No se puede abrir archivo"), file.errorString());
return;
}
QDataStream out(&file);
out << Alumnos;
}
I'm a beginner.