Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Identity Versus Value: QExplicitlySharedDataPointer holding data for QObject
Forum Updated to NodeBB v4.3 + New Features

Identity Versus Value: QExplicitlySharedDataPointer holding data for QObject

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • B Offline
    B Offline
    Beacon11
    wrote on last edited by
    #1

    Hello. My application contains a mixture of QML and regular Desktop Qt. The QML has a ListModel that displays data held in a QAbstractListModel. The data held by the QAbstractListModel is simply a list of QObjects that I call ListItems. The rest of the application runs off the same data, so the entire application shares that list. I wasn't really a fan of passing pointers around to share stuff since it started getting difficult keeping track of when stuff got deleted, so I moved the ListItems to have explicitly shared data (using QExplicitlySharedDataPointer) thinking I'd pass copies of them around that were all sharing data. That sounded nice and safe.

    However, then I ran into the fact that QObjects aren't supposed to be copied (http://qt-project.org/doc/qt-4.8/object.html#qt-objects-identity-vs-value). How should I be doing this? I would appreciate any advice!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      In your case, shouldn't all of your application elements rather access your list through the model ? That would avoid having the list playing around and having to synchronize your model (yes, you would be sharing the model rather than the list, but models are made for that kind of logic).

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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