Hello,
I am new user Qt and I have got problem. So, I don't know how to save QMap with structure to file. I will show code.

Qt Code:
  1. void Test::saveMap() {
  2. QString fileName = QFileDialog::getSaveFileName(this, trUtf8("Save map to file"), "", trUtf8("Map (*.ttx);;All files (*)"));
  3. if (fileName.isEmpty())
  4. return;
  5. else {
  6. QFile file(fileName);
  7. if (!file.open(QIODevice::WriteOnly)) {
  8. QMessageBox::information(this, trUtf8("Can't to open file."), file.errorString());
  9. return;
  10. }
  11. QDataStream out(&file);
  12. out.setVersion(QDataStream::Qt_4_6);
  13. out << map;
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. struct DataMap {
  2. QString name;
  3. QString name1;
  4. QString name2;
  5. };
  6.  
  7. ...
  8.  
  9. QMap<QString, DataMap> map;
To copy to clipboard, switch view to plain text mode 

QMap is declared as private - it is all ok. If I save QMap without structure (declaration: QMap<QString, QString> map) all is ok, but if I save QMap with structure DataMap, I have got a lot of errors. How does it fix? How to save QMap with structure to file?

Thanks.

Goodbye.