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. Sharing same data class through diferent qmlRegisterTypes
Forum Updated to NodeBB v4.3 + New Features

Sharing same data class through diferent qmlRegisterTypes

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 517 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.
  • O Offline
    O Offline
    osfesa
    wrote on last edited by
    #1

    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
    0

    • Login

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