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. C++ Singleton import inside Qt Creator's QML Designer
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qt creatorqmlsingletonimportdesigner
2 Posts 2 Posters 814 Views
  • 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.
  • b2softB Offline
    b2softB Offline
    b2soft
    wrote on last edited by b2soft
    #1

    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
    0
    • J Offline
      J Offline
      Jan80
      wrote on last edited by
      #2

      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
      0

      • Login

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