What is the standard textual representation of Qt's types?

97 views Asked by At

Edit:

I should clarify: I am seeking to serialize the values, not just the name of the type.


Is there a human-readable/textual format for Qt's builtin types? (For example, the ones registered in QMetaType or QVariant::Type.)

Looking at the source of QSettings, that "ini" format is created manually. There are giant switch blocks that manually serialize and deserialize the "ini" representation. It is also, unfortunately, not a standard - because it is part of the "private" implementation of QSettings.

Or is there no standard whatsoever for textual representation of Qt types?

1

There are 1 answers

2
Andrei R. On
class MyClass {};
Q_DECLARE_METATYPE(MyClass)

QVariant var = QVariant::fromValue<MyClass>(MyClass());
std::cout << var.typeName() << std::endl;

will print "MyClass". You can do it with any registered type as well: QMetaType::typeName(qMetaTypeId<int>())