QVariant isArray ?
-
wrote on 17 Feb 2022, 11:59 last edited by
Is there a generic way to identify if the data assigned to a QVariant is an array?
I know there is the type function, but I'm looking for something that may already exist before I re-invent the wheel.
-
Is there a generic way to identify if the data assigned to a QVariant is an array?
I know there is the type function, but I'm looking for something that may already exist before I re-invent the wheel.
@SPlatten What do you mean by array? QByteArray?
And what is the problem with type()? -
@jsulm , I was looking for a generic way of determining if the data stored in the QVariant was singular or multiplies like a QByteArray.
I just wanted to know if there was already a way of determining this.
wrote on 17 Feb 2022, 12:51 last edited by@SPlatten said in QVariant isArray ?:
I was looking for a generic way of determining if the data stored in the QVariant was singular or multiplies
Short answer: no
Long answer: it depends how you are using it.
QVariant::type()
will return an enum value to let you know what is the type of the stored value.
To be able to store a value into aQVariant
, this value has to be already known or register withQ_DECLARE_METATYPE()
QVariant::type() will let you know the variable type, and then you can get the according value with QVariant::value<TypeOfTheVariable>() -
@jsulm , I was looking for a generic way of determining if the data stored in the QVariant was singular or multiplies like a QByteArray.
I just wanted to know if there was already a way of determining this.
@SPlatten OK, now I understand.
I don't think there is already built-in functionality for this.
1/5