2

The QCursor class of Qt has as public static method called 'setPos'; I want to use this method in QML Javascript. So the question is quite straight forward: How to call this 'setPos' method from QML Javascript?

jondinham
  • 8,271
  • 17
  • 80
  • 137

1 Answers1

1

AFAIK you can't, as there's no QML QCursor equivalent and QCursor itself does not derive from QObject.

But you can make a simple custom class deriving from QObject that just calls the QCursor static methods from methods marked as slots or Q_INVOKABLE. To get out of having to create an object every time you want to call setPos(..), you can register your class as a singleton with the QML engine.

cmannett85
  • 21,725
  • 8
  • 76
  • 119