[SOLVED] Defining own QML type - can i define method ?
QML and Qt Quick
5
Posts
2
Posters
1.1k
Views
1
Watching
-
Hi, i was wondering about how i can define own C++ methods for QML component.
@
class TimeModel : public QObject
{
Q_OBJECT
Q_PROPERTY(int hour READ hour NOTIFY timeChanged)
Q_PROPERTY(int minute READ minute NOTIFY timeChanged)
...
@This is code example from documentation. Thereis defined properties, but i want to define method to which i will call later in QML code, like this:
@TimeModel {
id: tm
}..
tm.someMethod()
..@I didnt found Q_METHOD() in qt. Anny suggestions ??
-
There are 2 ways:
- mark methods with Q_INVOKABLE
- make them be public slots
-
No. Either one will work.