Questions tagged [qsharedpointer]

QSharedPointer is a Qt class which holds a strong reference to a shared pointer.

Introduced in Qt 4.5 QSharedPointer class represents a strong reference to a shared pointer. It is similar to boost::shared_ptr or std::shared_ptr.

The QSharedPointer is an automatic, shared pointer in C++. It is thread-safe and operates atomically on the pointer value.

QSharedPointer holds a shared pointer by means of an external reference count.

Official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

75 questions
0
votes
1 answer

Pass QNetworkReply pointer to QSharedPointer

One question about use of QSharedPointer in following scenario: I have a class with two QSharedPointers private class members: class xy{ ... private: QSharedPointer m_nam; QSharedPointer
0
votes
0 answers

Save QList> as QVariant

I have a problem saving a QList of QSharedPointer< MyClass > as QVariant in a derived QGraphicsItem class. MyClass is an abstract base class used as an interface. I made this to be able to up cast all 'MyClass subclasses' to the base MyClass and put…
RobRobRob
  • 67
  • 2
  • 10
0
votes
1 answer

Seg Fault when using QSharedPointers in qt5

I'm using qt5.5.1 with qt-creator 3.5.1 and am trying to set a style on a GeoDataPlacemark with a GeoDataStyle. It used to work fine, but after the Marble update to use shared pointers instead of direct pointers, my program seg faults. Using GDB,…
Eric Horng
  • 57
  • 1
  • 6
0
votes
2 answers

life cycle of QSharedPointer or std::shared_ptr

in my application I've a MainWindow (which is a QtMainWindow class) and a Acquisiton class (which is a QThread class) Here my very simplified Acquisiton class //entry point of the thread void Acquisition::run () { uint8_t* …
Titouan56
  • 6,932
  • 11
  • 37
  • 61
0
votes
0 answers

Wriring binary data from QSharedPointer gives unexpected file size

My issue at the moment is essentially that I can't seem to be able to write all the data that I want to disk. What I am trying to do is saving float values in binary format to disk, one after the other. There can be any even number of values between…
FreddyKay
  • 275
  • 1
  • 4
  • 13
0
votes
1 answer

How can I delete a QSharedPointer

I have written a wrapper around QTextEdit to use it like a QIODevice. I want to be able to use multiple wrapper with the same QTextEdit, so I may use different text color with each wrapper. To make this wrapper thread-safe I added a QMutex to…
AMDG
  • 955
  • 1
  • 9
  • 25
0
votes
1 answer

QSharedPointer Invalid Address specified to RtlFreeHeap

I have a program that makes heavy use of QSharedPointer. When I execute my program it runs fine, but when I debug it with GDB it starts throwing errors. "Invalid Address specified to RtlFreeHeap" is thrown in the following…
Timothy Baldridge
  • 10,455
  • 1
  • 44
  • 80
0
votes
0 answers

QSharedPointer getting destroyed early

I am using QSharedPointer for an object which contains slot function. My expectation is that even though the object that contains this pointer get destroyed but it would live on and process the QProcess::finished signal but it doesn't. I create a…
zar
  • 11,361
  • 14
  • 96
  • 178
0
votes
0 answers

Iterating over Qmap with QSharedPointers as values

I have a QMap that includes QSharedPointers as values. Everytime I try to loop through the map and qDebug the results I'm getting memory handling erros. Values of the map are objects of Team class which inherits from QObject. QMap…
mmok
  • 1
  • 1
0
votes
1 answer

QList::contains with a QSharedPointer

So I have a class which has an id data member and I'm using it in a QList> and I'm unsure about how to go about checking to see if there's an existing id in that QList. How would I go about doing that exactly as…
SuperWig
  • 155
  • 3
  • 14
0
votes
0 answers

What is the cost of calling member function via shared pointer?

It is often stated that dereferencing a smart pointer does not have notable performance impacts. (For example here: C Smart Pointer Performance) I am now wondering if this is really true. I understand that it could be, if operations on the object…
philipp
  • 1,745
  • 1
  • 14
  • 25
0
votes
0 answers

Qt Signal: Dereference QSharedPointer

I have a class Historymanager, that has an attribute of type QUndoStack. I can get the undoStack with a getter that returns QSharedPointer Now in a different class C, I have access to the historymanager and need to connect the signal…
RunOrVeith
  • 4,487
  • 4
  • 32
  • 50
0
votes
1 answer

Access to referenced elements in QList and QSharedPointer

There is a QList member variable named m_noteList containing QSharedPointer elements of class Note. private: QList< QSharedPointer > m_noteList; If a new note is created, its reference is appended to the list: void…
user2366975
  • 4,350
  • 9
  • 47
  • 87
0
votes
1 answer

should getters from an object return references pointers or QSharedPointers?

I'm storing an object internally(private) as a QSharedPointer(so it will delete it). For the getter should I return a reference a raw pointer or a QSharedPointer? Also I'm not sure what http://qt-project.org/wiki/SharedPointersAndQmlOwnership means.…
Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141
0
votes
0 answers

Secure shared pointer for Qt

Since Qt uses its horrible archaic ptr mechanisms, using their QSharedPointer is mostly not practical. The moment you set a QSharedPointer to nullptr while being in a slot could very well result in undefined behavior (crashing). Also, the design of…
abergmeier
  • 13,224
  • 13
  • 64
  • 120
1 2 3 4
5