Skip to content

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

Open
jkarneges wants to merge 1 commit intomainfrom
jkarneges/variant-type-enum
Open

add VariantType::Type to replace direct use of QMetaType::Type#48321
jkarneges wants to merge 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.

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.

1 participant