Frage

I'm currently trying to convert my QList<QString*> to an enum version so it can be faster.

I would like to do the following, QList<EnumType*>. I am wondering if there is any reason I shouldn't do this. I could really benefit from the pointer in the QList for my next step which is to convert it to a QQmlListProperty<EnumType> which takes a QList<EnumType*>.

War es hilfreich?

Lösung

There's no point in managing enum values or QStrings via pointer. Just use QStringList (which is a QList<QString>) or QList<SomeEnum>. QQmlListProperty is for managing QObjects, as the documentation says:

Note: QQmlListProperty can only be used for lists of QObject-derived object pointers.

Neither QStrings nor enums are. What the best solution is to expose the list to QML depends on your use case.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top