Skip to content

add VariantType::Type to replace direct use of QMetaType::Type#48321

Merged
jkarneges merged 1 commit intomainfrom
jkarneges/variant-type-enum
Apr 10, 2026
Merged

add VariantType::Type to replace direct use of QMetaType::Type#48321
jkarneges merged 1 commit intomainfrom
jkarneges/variant-type-enum

Conversation

@jkarneges
Copy link
Copy Markdown
Member

#48320 mentions that working with variant types still involves QMetaType. This PR introduces our own substitute enum, with values that are identical to those of QMetaType, and updates the whole codebase to use it everywhere. This way, variant call sites don't have to reference QMetaType directly.

The enum looks like this:

#include <QMetaType>

namespace VariantType {
	enum Type {
		Invalid = QMetaType::UnknownType,
		Bool = QMetaType::Bool,
		Int = QMetaType::Int,
		Double = QMetaType::Double,
		LongLong = QMetaType::LongLong,
		String = QMetaType::QString,
		ByteArray = QMetaType::QByteArray,
		Hash = QMetaType::QVariantHash,
		Map = QMetaType::QVariantMap,
		List = QMetaType::QVariantList
	};
}

Since the values are the same, there should be no change in behavior.

Note that there is still some remaining direct usage of Qt's meta type system via the Q_DECLARE_METATYPE macro, which enables storing user-defined types in QVariant. We'll address that separately.

@jkarneges jkarneges requested a review from a team April 10, 2026 16:45
@jkarneges jkarneges merged commit 13de5fb into main Apr 10, 2026
19 checks passed
@jkarneges jkarneges deleted the jkarneges/variant-type-enum branch April 10, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants