2

I have a list of QObjects* and want to add them to my DataModel. But the datamodel needs a QVariant instead of QObject.

Is is possible to convert QObjects to QVariant?

DevCoder
  • 111
  • 1
  • 3
  • 7

1 Answers1

1

Yes, because it is not a type supported by QVariant::Type it falls back to QMetaType::Type support. You must use QVariant::setValue(..) or QVariant::fromValue(..) to set it as the QVariant constructors don't have an overload for QObject*.

cmannett85
  • 21,725
  • 8
  • 76
  • 119