Questions tagged [qshareddata]

In the QT framework, QSharedData class is a base class for shared data objects.

In the QT framework, QSharedData class is a base class for shared data objects.

http://doc.qt.io/qt-5/qshareddata.html

14 questions
5
votes
2 answers

QSharedDataPointer with forward-declared class

The Qt documentation suggests that using the QSharedDataPointer with a visible implementation of its inferior is not typical. So according to the small example snipped in the docs, I came up with the following source (SSCCE). The interface:…
Kamajii
  • 1,826
  • 9
  • 21
5
votes
4 answers

QSharedData and inheritance

I'm trying to make a type system while using QSharedData. The idea is simple, there will be a number of different data types, each of which is going to be derived from the base abstract class. I want to use QSharedData to store the actual data in…
SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
5
votes
1 answer

Should I implement all my data classes as QSharedData and use it with QSharedDataPointer?

I am a Qt beginner and need to write some data classes. Would it be a good approach to write all these classes as in the QSharedDataPointer example (here), or is this too much overhead (besides the fact it is more work)? My classes in nature a very…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
4
votes
1 answer

Is 'implicit sharing' heritable from Qt classes?

If I create a subclass of an implicitly shared Qt class (e.g., QList), will my subclass be implicitly shared as well? I read the brief introduction to implicit sharing located in the QtCore5.3 documentation, but I didn't see any mention of…
FalafelPita
  • 293
  • 1
  • 8
4
votes
2 answers

QSharedData and operator=

Recently I wanted to implement implicit sharing functionality like Qt does with its QSharedData and QSharedDataPointer classes, so I took a look at their sources and in the place of QSharedData I found these three lines: private: // using the…
jcxz
  • 1,226
  • 2
  • 12
  • 25
3
votes
3 answers

Private (hidden) QSharedData

I have a class that has some data members that I want to be hidden from the caller (because including the headers for their types significantly increases the compile time, and it would require every project using this class to add an additional path…
Sebastian Krysmanski
  • 8,114
  • 10
  • 49
  • 91
3
votes
1 answer

Can I use QSharedData while inheriting from QObject?

How do I hide the private implementation (implicit sharing) in Qt: I have Employee.cpp the following in my Employee.h header: #include #include class EmployeeData; class Employee: public QObject { Q_OBJECT public: …
Derick Schoonbee
  • 2,971
  • 1
  • 23
  • 39
3
votes
1 answer

QSharedData crash

I have an infrequent but fairly consistent crash in my Qt 5.2.0 application which I am having a heck of a time diagnosing, but believe to be related to QSharedData. The application is highly multi-threaded, which is presumably part of the…
Mike Blackwell
  • 487
  • 1
  • 6
  • 12
2
votes
1 answer

QImage copy on write

is QImage based on QSharedData ? Do Qimage follow pimpl or copy on write ? e.g. would copying(through copy con or assignment) an Qimage make a deep copy of pixels ?
Neel Basu
  • 12,638
  • 12
  • 82
  • 146
1
vote
1 answer

QT qSharedDataPointer dynamic casting?

I am trying to perform the following cast and I can't find a way either in the QT documentation or online to make this dynamic cast work which has been confusing: class Entity : public QSharedData { public: typedef…
Klypto
  • 434
  • 1
  • 3
  • 14
1
vote
2 answers

Any way to automatically generate QSharedData-based structures?

Qt has a build-in supprt for creating objects with integrated reference counting via QSharedData and QSharedDataPointer. All works great, but for each such object I need to write a lot of code: QSharedData-based implementation class with constructor…
grigoryvp
  • 40,413
  • 64
  • 174
  • 277
0
votes
0 answers

Do I explicitely need to declare destructor in QSharedData's inherited class?

My question concerns whether I explicetely need to declare a destructor in my main class and in the QSharedData's inherited one, in order to prevent memory leaks. In this example I have an Employee class which handles its data through EmployeeData.…
Spatz
  • 21
  • 1
  • 7
0
votes
2 answers

Alternate implementations of QSharedDataPointer and QSharedData

I was wondering if anyone has come across a system like QSharedDataPointer and QSharedData for implicit sharing, which is appropriate for use with the pimpl idiom, in an alternative library to Qt? I have been trying to avoid adding extra…
Jonathan Pierce
  • 184
  • 1
  • 1
  • 11
-1
votes
1 answer

Confusing about implicit sharing concept in Qt

According to implicit sharing concept in following example we must experience low memory usage in Windows Task Manager. We create 1000000 object in a for loop from Employee class and it might share its internal data (EmployeeData class) between…
Reza Ebrahimi
  • 3,623
  • 2
  • 27
  • 41