Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.4.1
Description
Using a list of Foobar pointers defined like
class Foobar : public QObject { Q_OBJECT QML_ELEMENT QML_UNCREATABLE("Read only") Q_DISABLE_COPY(Foobar) public: Foobar(QObject* parent = nullptr) : QObject(parent) {} Q_INVOKABLE int baz() const { return 42; } }; class Druggeljug : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON public: Druggeljug(QObject* parent = nullptr) : QObject(parent) { for (int i = 0; i < 5; ++i) { m_foos.append(new Foobar(this)); } } Q_INVOKABLE QList<Foobar*> getList() const { return m_foos; } private: QList<Foobar*> m_foos; };
used in
function showList() { const l = Druggeljug.getList() for (const foo of l) { console.log(foo.baz()) } }
works at runtime, but cannot be compiled:
Warning: main.qml:12:30: Could not compile function showList: return type QList<Foobar*> cannot be resolved [compiler] const l = Druggeljug.getList() ^^^^^^^
Attachments
Issue Links
- duplicates
-
QTBUG-107773 list types are inconsistent
- Closed
- is duplicated by
-
QTBUG-110248 qmlsc: QList<Foo*> cannot be resolved
- Closed
- relates to
-
QTBUG-104744 QML_SEQUENTIAL_CONTAINER doesn't work with lists of object types
- Closed
-
QTBUG-108155 QmlEngine complains binding of QmlListProperty to QList <QObject *>
- Closed