Qt Forum

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

    Sharing same data class through diferent qmlRegisterTypes

    QML and Qt Quick
    1
    1
    425
    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.
    • O
      osfesa last edited by

      Hi all.

      I've an app running Qt 5.2.1 where I have several qmlRegisterType classes working.
      All of them need the same data, and they have indeed the same, with a singleton class.

      I know it's not the best way to do it.
      And my question is how can I pass a reference of my class to all qml register types?

      I tryed adding an int to QQmlApplicationEngine as contextProperty, and can read it on QML.
      But I need to pass a reference of my object, from main.cpp (I think), to QML side and then... how can I pass this reference to C++ side?
      How should be the C++ constructor of these qmlRegisterTypes?
      How I should initialize qmlRegisterTypes in QML to get my class reference as argument?

      Am I wrong? Or is there another better way to do it?

      My register types inherit from QObject or QQuickPaintedItem:

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