Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Calling static method of a "qmlRegisterUncreatableType" class

Calling static method of a "qmlRegisterUncreatableType" class

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bmcd33
    wrote on last edited by
    #1

    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.

    Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved