0

I want to expose a QVariantList from C++ to QML. The QVariantList can contain data of types Integer, QString and QStringList. I want to use it as a model for a QML ListView and also I want to use a different Delegate for the elements depending on the type in the QVariantList. So data of type Integer are displayed differently than data of type String and StringList.

  • How can I detect the type of the elements in the QVariantList in QML?
  • How can I use a different delegate depending on the type?

I need a solution where I can change the exposed QVariantList and the ListView and its delegates will change.

KernelPanic
  • 2,328
  • 7
  • 47
  • 90
Nathan
  • 7,099
  • 14
  • 61
  • 125

1 Answers1

0

I have found no way of determining the type of a QVariant in QML, but I am using a different type now that exposes its type trough a string.

For the question of how to create a ListView with different delegates, the solution can be found here: Different delegates for QML ListView

Community
  • 1
  • 1
Nathan
  • 7,099
  • 14
  • 61
  • 125