如何在Qt中保存包含2个QMap数据的文件?

发布于 2024-09-05 10:37:23 字数 423 浏览 1 评论 0原文

可能的重复:
使用 Qt 进行序列化

我有 2 个类型为 QMap 的数据:

1.QMap 小说; QString tempChapter; QString tempStory;

2.QMap组合; int tempInd; QString tempChap;

我的问题是: 我怎样才能将这两个数据保存到一个文件中? 如果保存成功,我该如何加载这2个数据? 请也插入代码,因为我是一个初学者 C++ 程序员,对 OOP 不太了解,, 请尽快回答!非常感谢! :)

Possible Duplicate:
Serialization with Qt

I have 2 datas which type is QMap:

1.QMap novel;
QString tempChapter;
QString tempStory;

2.QMap combo;
int tempInd;
QString tempChap;

my question is:
How can I save these 2 Datas into a single file??
And if it's successfully saved, how can I load these 2 datas?
Please insert the code too because I'm a beginner C++ programmer and dont know much about OOP,,
please answer this ASAP! Thank you very much! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最美的太阳 2024-09-12 10:37:23

QDataStream 支持 qt 中的所有基本集合,检查 QMap 文档,因为您只存储其他基本 qt 类型和整数,所以应该没问题

All of the basic collections in qt are supported by QDataStream check for support in the QMap docs, as you are only storing other basic qt types and ints you should be ok

柠檬 2024-09-12 10:37:23

基本上,您必须自己想出一种格式来存储数据。我建议阅读一些有关序列化的内容。请阅读本文,了解有关 C++ 中序列化的一些常规信息。

Basically, you will have to think of a format to store your data in yourself. I would suggest to read something about serialization. Read this for some general information about serialization in C++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文