Calling static method of a "qmlRegisterUncreatableType" class

  • Is there a way to call functions of c++ classes from qml without creating an object?

    For example, I have a c++ class: OAuth, in it I have:
    Q_INVOKABLE static bool login(const QString &username, const QString &password);

    I register OAuth as an uncreatable type using: qmlRegisterUncreatableType<OAuth>("oauth", 1, 0, "OAuth", "Error.....");

    but when I try to call OAuth.login(...., ....) from qml, it gives me:

    "TypeError: Property 'login' of object [object Object] is not a function"

    It works when I register OAuth using "qmlRegisterType" and then create an OAuth variable, but I would much rather be able to call the function without having to instantiate an object.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.