Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved C++ Singleton import inside Qt Creator's QML Designer

    QML and Qt Quick
    qt creator qml singleton import designer
    2
    2
    573
    Loading More Posts
    • 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.
    • b2soft
      b2soft last edited by b2soft

      Hello, I have a C++ singleton registered for qml using such code:

      engine.setObjectOwnership( wrapper, QQmlEngine::CppOwnership );
      qmlRegisterSingletonType<QMLWrapper>( "QMLWrapper", 1, 0, "QMLWrapper", getWrapper );
      

      In QML I import it using plain import and use as is stated below:

      import QMLWrapper 1.0
      ...
      QMLWrapper.onLoginButtonClicked("login", "pass")
      

      But when I try to enter Form Editor inside Qt Creator, I get error:
      0_1526583350345_8163dc64-6328-41f9-8382-74bcd4ba852e-image.png

      So, is there any way to keep Form Editor working without commenting import statement?

      I use Visual Studio + Qt Plugin to build an application, Qt Creator is used only for editing QMLs

      Thanks

      1 Reply Last reply Reply Quote 0
      • J
        Jan80 last edited by

        I know this answer is a bit late, but one solution that comes to my mind is to separate UI from logic. Create one file (e.g. a ui.qml file) for your UI and use it in another qml file.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post