Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Make QtCreator recognize the use of qmlRegisterSingletonType (QML module not found)
Forum Updated to NodeBB v4.3 + New Features

Make QtCreator recognize the use of qmlRegisterSingletonType (QML module not found)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 161 Views 2 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.
  • H Offline
    H Offline
    HubertDu47
    wrote on last edited by
    #1

    Hello everybody!

    I have a simple question about QML module. I am using Qt 5.13.2 and I have declared C++ singleton in the main.cpp, like this:

    qmlRegisterSingletonType(QUrl("qrc:/Something.qml"), "namespace.other", 1, 0, "Something");
    

    That's working, no problem.

    But if I create a method which doing this (to simplify my declarations):

    int registerQmlSingleton(const QString &namespaceName,
                                         const QString &singletonName,
                                         int versionMajor = 1,
                                         int versionMinor = 0)
    {
        return qmlRegisterSingletonType(
                    QUrl(QString(CoreConstants::Qml::qmlSingletonPath).arg(singletonName)),
                    namespaceName.toLatin1().constData(),
                    versionMajor,
                    versionMinor,
                    singletonName.toLatin1().constData());
    }
    

    All build and run without problems, but in the editor QtCreator doesn't recognize the modules and warns in QML files for "namespace.other": QML module not found.

    Is there a way to tell to QtCreator that a module is registered? Something with comment in code, or else?

    Thanks for your help!

    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