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)'
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)'
To copy to clipboard, switch view to plain text mode
In my registro.h I have this:
typedef struct curData{
int Promedio;
}cursoRegistro;
typedef struct alumData{
int Codigo;
QList <cursoRegistro> Cursos;
int Promedio;
}alumnoRegistro;
QList <alumnoRegistro> Alumnos;
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;
To copy to clipboard, switch view to plain text mode
My function to save the file (in registro.cpp) is:
void Registro::guardarArchivo()
{
if (nombreArchivo.isEmpty()) {
return;
}
QFile file(nombreArchivo
);
QMessageBox::information(this, tr
("No se puede abrir archivo"),
file.
errorString());
return;
}
out << Alumnos;
}
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;
}
To copy to clipboard, switch view to plain text mode
I'm a beginner.
Bookmarks