系列化提升Qt中:这是一个正确的方法是什么? [英] Boost serialization in Qt: is it a proper way?

查看:267
本文介绍了系列化提升Qt中:这是一个正确的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个应用程序是基于Qt的序列数据。

I'm thinking about serializing data in an application which is Qt-based.

从本质上讲就是我要序列化是我的层次模型,它是由来自不同派生类的,说,TreeModelItem:

Essentially what I'm going to serialize is my hierarchical model, which is composed of different classes that derive from, say, TreeModelItem:

class TreeModelItem
{
protected:
    QList<TreeModelItem *> m_children;
//...
};

我应该学习的boost ::系列化,并用它去?

Should I study boost::serialization and go on with it?

有没有隐藏的墙壁,我可以顺便打?例如。而(反)序列的子元素,或恢复定制葛槽连接时?我希望专家的意见。

Is there any hidden wall I can hit by the way? E.g. while (de)serializing child elements, or when restoring custom singal-slot connections? I hope for the advice of experts.

推荐答案

和QDataStream 一些流行的Qt对象的支持(德)序列化。你可以在这里查询哪些
在Qt的的方法是使用它。

QDataStream supports (de)serialization of some popular Qt objects. You can check which ones here. The "Qt" way would be to use that.

然而,没有什么preventing您使用提升,但你将不得不从头再来实施基本对象,如的QList序列化,它可以是烦人。

However, there's nothing preventing you from using boost, but you will have to implement the serialization for basic objects such as QList all over again, which can be tiresome.

请注意,如果你有自定义对象,如您TreeModelItem,你就必须提供一个运营商的LT;&LT;你自己的。

Note that if you have custom objects, such as your TreeModelItem, you would have to provide an operator<< of your own.

关于信号/插槽的系列化:据我所知Qt不支持此ATM,我相信Qt的团队取得了这种方式故意。如果你有兴趣,为什么,也许可以读是有益的。

Regarding the serialization of signals/slots: afaik Qt doesn't support this atm, and I believe the Qt team has made it this way intentionally. If you're interested why, maybe this read can be helpful.

这篇关于系列化提升Qt中:这是一个正确的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆