M
M
Maximmortalis2020-11-17 18:51:30
Qt
Maximmortalis, 2020-11-17 18:51:30

Is it possible to force QT Creator to see the methods of a class returned by a function?

There is a class, let's call it MyClassList, in which there is a QList containing a set of another class. Let 's say QList<MyClass> _items. There is a need to call QList elements in QML, while so that the IDE understands that MyClass is being called and substitutes the available methods and functions. Implementation of a simple

Q_PROPERTY(MyClass *last READ getLast) 
MyClass *getLast() {return &_items.last()}
was successful and the IDE perfectly understood what they wanted from it and deduced all subsequent methods and parameters in QML as it was required of it (myClassList.last.someMethod for example). But the catch is that when you want to call an element by index, for example through
Q_INVOKABLE MyClass *getItem(qint32 index) 
{return &_items[index]}
For some reason, the IDE refuses to accept MyClass and provide further possible methods. No, of course, if you add them manually, everything works fine, but the task is to transfer the written library to a third-party developer, and he could intuitively understand what this class can do, what methods and functions are in it without the need to scour the code yourself. Unfortunately, I'm still not familiar enough with QT, so I would like to know how to be here. And, after all, a question that concerns me personally: is it possible to make QML understand the C ++ operator[] of a custom class so that it can be called in QML like myClass[0].someMethod?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question