Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道,QVariant 如何在内部存储,int,QMap,QList,...
我的意思是什么是内部数据结构/实现?在 QVariant 中存储和检索类型(int、float)的开销是多少?
快速浏览一下代码会发现,aQVariant基本上是union几种原始类型(int等float)的 a、一个QObject指针,以及一个void*指向任何其他非 aQObject和非原始类型的指针。还有一个类型数据成员允许它知道当前实际存储的内容。开销似乎只是存储到结构的成员,检查类型兼容性并可能进行转换(例如 int 到 float)
QVariant
union
int
float
QObject
void*