开发者

How QVariant Works Internally?

开发者 https://www.devze.com 2023-02-10 18:07 出处:网络
I want to know, How QVariant can internally stores, int, QMap, QList,... I mean what is the internal data-structure/Implementation? What is the overhead of storing and retrie开发者_运维百科ving types

I want to know, How QVariant can internally stores, int, QMap, QList,...

I mean what is the internal data-structure/Implementation? What is the overhead of storing and retrie开发者_运维百科ving types (int, float) in QVariant?


A quick look at the code reveals that a QVariant is basically a union of several primitive types (int, float etc'), a QObject pointer, and a void* pointer for anything else that is not a QObject and not a primitive. There is also a type data member that allows it to know what's actually currently stored there. The overhead appears to be not much more than storing to a member of a struct, checking that for type compatibility and possibly making a conversion (int to float for instance)

0

精彩评论

暂无评论...
验证码 换一张
取 消