If you type is base on QObject, you have to take care to avoid double free if they have a parent. . If T is a derived type of the template parameter of this class, QSharedPointer will perform an automatic cast. It is a bug if you put just a pointer to your item to QChache and at the same time such pointer is managed by QSharedPointer. C++ (Cpp) QSharedPointer::StopTimer - 1 examples found. If the receiver needs a reference of the sender object, it should retain it in a smart pointer. This step is necessary since the only other way of keeping the engine from assuming ownership would be to give the object a parent, which is out of the question since. Detailed Description The QSharedPointer class holds a strong reference to a shared pointer The QSharedPointer is an automatic, shared pointer in C++. You can rate examples to help us improve the quality of examples. [noexcept] const T *QSharedDataPointer:: constData const. One of the important member functions of QSharedPointer is isNull(), which returns true if the pointer is null, and false otherwise. This maintains a standard interface across Qt classes. This project implements the Event and BlockingQueue in two. However, if the string contains non-numeric characters, it cannot be converted to an integer, and any attempt to convert it will fail. See QWeakPointer::toStrongRef() for an example. #include <QWidget> #include <QSpinBox> class MyWidget : QWidget // A template widget to be placed in MainWindow { Q_OBJECT public: MyWidget () { this->spinBox = new. A shared pointer is null by default, or when set to 0/nullptr explicitly:C++ (Cpp) QSharedPointer::node - 2 examples found. There are not so much Qt examples and demos with QSharedPointer because of the general concept for memory management in Qt using parent–child hierarchy of QObject. 2 version on Ubuntu 18. It behaves exactly like a normal pointer for normal purposes, including respect for constness. A more complex program sending QSharePointer objects using slots has a similar situation with GDB, that can be reproduced with the previous example. It is similar to std::shared_ptr in C++. You can rate examples to help us improve the quality of examples. See QWeakPointer::toStrongRef() for an example. The simplest approach to the problem is to simply not mix and match the two memory management schemes. Someone has to manage the memory. C++ (Cpp) QSharedPointer::GetFormulaRadius - 2 examples found. com: 30. data (); } When you delete the pointed-to object, data () will be null. Commented defines are for "not compiling" parts. It works like variables in Java and CPython, or like std::shared_ptr. There are not so much Qt examples and demos with QSharedPointer because of the general concept for memory management in Qt using parent–child hierarchy of QObject. This function was introduced in Qt 5. As reference the example tested on cross environment using GDB:Member Function Documentation QScopedArrayPointer:: QScopedArrayPointer Constructs a QScopedArrayPointer instance. Therefore, to access the pointer that QWeakPointer is tracking, you must first promote it to QSharedPointer and verify if the resulting object is null or not. QSharedPointer:: objectCast() works reliably across DLL boundaries, but QSharedPointer:: dynamicCast() and std::dynamic_pointer_cast() don’t. If this (that is, the subclass instance invoking this method) is being managed by a QSharedPointer, returns a shared pointer instance pointing to this; otherwise returns a null QSharedPointer. Some operators are missing by design, for example the assignment operator: QScopedPointer<int> i(new int(42)); i = new int(43); // will not compile i. The shared heap object is deleted only when the last shared pointer to it is destroyed. Usually one puts this (note that the typedefed name is used as string argument): qRegisterMetaType< QSharedPointer<TestClass> > ( "SharedTestClass" );My intention was, since I had to store the actual data in another QSharedPointer, to make a connect on that shared pointer that tells the other widget. Example: Say you have Guest object with 2 inheritances: Now we can make Guest inherit from QObject and children inherit from. As reference the example tested on cross. The requester class should also be in charge of managing the memory of the pointer it created. is not possible perform some atomic operation on two threads with two core processor at the same time. T must be a subclass of QObject. If this metatype represents an enumeration, this method returns a metatype of a numeric class of the same signedness and size as the enums underlying type. [quote author="situ117" date="1304279927"] I was reading about QSharedPointer in Qt. Qt 6 youtube videos by Bry. 1. This is useful, for instance, for calling deleteLater () on a QObject instead: QSharedPointer<MyObject> obj = QSharedPointer<MyObject> (new MyObject, &QObject::deleteLater); An alternative is using QPointer instead of QSharedPointer, citing the documentation: The QPointer class is a template class that provides guarded. Call doc:QSharedPointer :: data () to get a pointer to the referenced class; Make sure the QML engine doesn't assume ownership: doc:QDeclarativeEngine :: setObjectOwnership (P). QSharedPointer is an EXTERNAL to the class and implements a reference counting pointer to a single instance of a class. Detailed Description. Smart pointers on the other hand, is more a category than a specific type, including shared pointers, auto. See QWeakPointer::toStrongRef() for an example. The QSharedPointer class holds a strong reference to a shared pointer. This function was introduced in Qt 4. Exactly. A data stream is a binary stream of encoded information which is 100% independent of the host computer's operating system, CPU or byte order. The problem is, that when implementing a QSharedAbstractItemModel, like the QAbstractListModel, you need to deal with raw pointers. For example, canConvert(QMetaType::fromType<int>()) would return true when called on a variant containing a string because, in principle, QVariant is able to convert strings of numbers to integers. You can inherit this class when you need to create a QSharedPointer from any instance of a class; for instance, from within the object itself. The memory corruption can happen if Team object is destroyed before reading its pointer from QMap. But in addition, QQueue provides three convenience functions. // OK QSharedPointer < QObject > object3(new QObject); // OK} Using a Mutex to Protect the Integrity of Data. This step is necessary since the only other way of keeping the engine from assuming ownership would be to give the object a parent, which is out of the question since. static PySide2. all provide a data() function to access the underlying data of a Qt class. h","path":"src/corelib/tools/qalgorithms. Use qSharedPointerCast (): QSharedPointer <Switch> mySwitchTest= qSharedPointerCast<Switch> (myState); Or call staticCast () on the smart pointer: QSharedPointer <Switch> mySwitchTest= myState. You can rate examples to help us improve the quality of examples. 5k 15 97 178. Commented defines are for "not compiling" parts. QScopedPointer intentionally has no copy constructor or assignment operator, such that ownership and. 212: 213: This class is never instantiated directly: the constructors and: 214 In the example above, the template specialization for the clone() function calls the EmployeeData::clone() virtual function. As a general guideline, if you are not sharing your pointers between multiple users, use a QScopedPointer, otherwise use a QSharedPointer. Commented defines are for "not compiling" parts. MyClass * myIns = new MyClass (); QSharedPointer<MyClass> asp ( myIns); QVariant aVariant = QVariant::fromValue( asp); To copy to clipboard, switch view to plain text mode. QSharedPointer. QScopedPointer has its copy constructor and assignment operator disabled. QSharedPointer. . This function was introduced in Qt 4. This blog post is the first in a series that will cover using OpenGL with Qt. The interface: Model. It behaves exactly like a normal pointer for normal purposes, including respect for constness. qt. The QSharedPointer is an automatic, shared pointer in C++. A simple code that could reproduce the issue. The example above tests that mkdir() outputs the right warning when invoked with an invalid file name. But, it all depends on your use case. But you might miss the more convenient BlockingQueue in Java/Python. The QSharedPointer is an automatic, shared pointer in C++. 24. It behaves exactly like a normal pointer for normal purposes, including respect for constness. What is the point of emitting a QSharedPointer? The worker thread reads the files computes the data allocates and fills the memory with data, wraps it in QSharedPointer and passes it to the mainThread, which is used for plotting. This looks to me as a Bug in Qt but I couldn't find an issue and I am not sure if some compiler settings are wrong. This is what I've done: class blabla: public QThread { Q_OBJECT . It is also possible to allow integer multiples and integer powers of the specified tick step with setScaleStrategy. [/quote] That is a good example to be careful with smart pointers. C++ Class Qt 스마트 포인터 (QSharedPointer, QScopedPointer, QPointer) 스마트 포인터는 C++표준 포인터의 모든 기능을 가지고 있으며 자동 가비지 컬렉션 기능을 제공하는 클래스이다. Member Type Documentation typedef QSharedDataPointer:: Type. Here's an example: void removeData() { QSharedPointer<DataPoints> dataPoint01(qobject_cast<DataPoints*>(sender())); // QList<QSharedPointer<DataPoints>> dataList; dataList. The QSharedPointer class holds a strong reference to a shared pointer The QSharedPointer is an automatic, shared pointer in C++. Smart pointers with PythonQt. QGroupBox: Supports the box model. QSharedPointer < T > QEnableSharedFromThis:: sharedFromThis If this (that is, the subclass instance invoking this method) is being managed by a QSharedPointer, returns a shared pointer instance pointing to this; otherwise returns a null QSharedPointer. Passing data through threads is a common task in multi-thread programming. The Qt docs say that Q_DECLARE_METATYPE is necessary in case one has a connect being a queued connection. Log in JoinPimpl + QSharedPointer - Destructor = Disaster. Immediately after construction both pointers go out of scope. or if you already have a reference to a pointer, then use the reset () method as follows: Qsharedfoo. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. However, upon deleting. Qt로 프로그래밍할 때 메모리 관리 문제 (메모리 관리 불량으로 인한 메모리 누수 및 버그. Depending on your use case that might be a better. Adding a Q_DECLARE_METATYPE () makes the type known to all template based functions, including QVariant. If somehow the object/container survives so does the smart pointer and the allocated memory. Their main advantage is reducing memory leaks and bugs due to poor memory management. Previously i had done this: Code: MyObject * object; // Subclass of QObject. Guarded pointers are useful whenever you need to store a pointer. Qt also provides QSharedPointer, an implementation of a reference-counted shared pointer object, which can be used to maintain a collection of references to an individual pointer. C++ (Cpp) QSharedPointer::GetP2 - 2 examples found. If we have smart pointers in Qt, why old C type pointers are preferred ? Reply Quote 0. If a ptr2's template parameter is different from a ptr1's, 1008. GetInfo(9) GetRemoteId(8) AddChildren(5). }; Q_DECLARE_METATYPE (blabla) But this code is giving me Error: In copy constructor ‘QThread::QThread (const QThread&)’: instantiated from ‘void. QSharedPointer will delete the pointer it is holding when it goes. Since a QSharedPointer is used, multiple QCPCurves may share the same data container safely. QSharedPointer:: QSharedPointer (const QWeakPointer < T > &other) Creates a QSharedPointer by promoting the weak reference other to strong reference and sharing. To have that guarantee, use toStrongRef(), which returns a QSharedPointer object. QScopedPointer intentionally has no copy constructor or assignment operator, such that ownership and. But I've not seen it much in use in source code of Examples and Demos. When removeData() returns, any further attempts to reference the sender is undefined behavior. . The QSharedPointer is an automatic, shared pointer in C++. For example, when saving the plot to disk. Parenting in Qt affects object freeing with some kind of pseudo garbage collection. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. See also QSharedPointer and QScopedPointer. The item object can be destroyed by QSharedPointer destructor, so QChache will have invalid pointer. Resets this QSharedPointer object to point to t instead. h","path":"src/corelib/tools/qalgorithms. It behaves exactly like a normal pointer for normal purposes, including respect for constness. It can happen, since QObject may be destroyed by its parent. in Qt-using projects. QPointer:: ~QPointer () Destroys the guarded pointer. The index is used by item views, delegates, and selection models to locate an item in the model. If you need a QSharedPointer, don't set. cpp Project: Samt43/QmlMusicPlayerUIQSharedPointer guarantees that the object isn't deleted, so if you obtain a non-null object, you may use the pointer. QList::contains algorithm is based on == operator. When the last associated QSharedPointer goes out of scope, the object will be deleted. It should work if the code is put into one function block. The exception is pointers derived from QObject: in that. See Customizing QFrame for an example. To have that guarantee, use toStrongRef(), which returns a QSharedPointer object. You can rate examples to help us improve the quality of. I have a problem with QSharedPointer and QVector in this lines of my code: If tokencount == 2. See also append() and insert(). If somehow the object/container survives so does the smart pointer and the allocated memory. These are the top rated real world C++ (Cpp) examples of QSharedPointer::isSelected extracted from open source projects. If we have smart pointers in Qt, why old C type pointers are preferred ? Reply Quote 0. But I've not seen it much in use in source code of Examples and Demos. They are often. If used in this way, you can pass around these references and use them like pointers, and. You can rate examples to help us improve the quality of examples. C++ (Cpp) QSharedPointer::at - 10 examples found. h file like: #include "myclass. 4, but was reborn in 4. 5. 1009. Examples and Tutorials Supported Platforms What's new in Qt 6 Qt Licensing Overviews Development Tools User Interfaces Core Internals. qRegisterMetaType< QSharedPointer<TestClass> >("SharedTestClass"); in main() not as a global variable. QSharedPointer guarantees that the object isn't deleted, so if you obtain a non-null object, you may use the pointer. C++ (Cpp) QSharedPointer::update - 7 examples found. 11. qRegisterMetaType< QSharedPointer<TestClass> >("SharedTestClass"); in main() not as a global variable. T must be a subclass of QObject. 4. A class derived from EmployeeData could override that function and return the. A mutex is an object that has lock() and unlock() methods and remembers if it is already locked. [quote author="Andre" date="1306394817"]In that case, I think you need to register them. If you call deleteLater () in the object's destructor and put an object on the stack - deleteLater () is called when the object goes out of scope. // Create pointer in constructor. reset(new int(43)); // correct . data());@ Then I have a number of SLOTS connected to this SIGNAL. reset (rawFoo); But as mentioned in the beginning, these are not equal. The same is for tokencount == 1. Maybe I have bad expressed. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. Thanks for any suggestion and comment, JulioHere's an example: void removeData() { QSharedPointer<DataPoints> dataPoint01(qobject_cast<DataPoints*>(sender())); // QList<QSharedPointer<DataPoints>> dataList; dataList. The exception is pointers derived from QObject: in that. It behaves exactly like a normal pointer for normal purposes, including respect for constness. QSharedPointer guarantees that the object isn't deleted, so if you obtain a non-null object, you may use the pointer. This function was introduced in Qt 5. std::shared_ptr<Exercise> americanExercise = std::make_shared<AmericanExercise> (settlementDate, in. It behaves exactly like a normal pointer for normal purposes, including respect for constness. QTest. The following custom cleanup handlers exist: QScopedPointerDeleter - the default, deletes the pointer using delete. If I have to share this instance in C++, I'll use QSharedPointer or std::shared_ptr. QSharedPointer QSharedPointer (X *)I have just found out that the QVector copy constructor (& move constructor) is very different from that of a std::vector! The QVector implements a variation on the COW pattern, whilest std::vector is a deep copy of the object. C++0x smart pointers std::shared_ptr<> The shared_ptr is a reference-counted pointer that acts as much as possible like a regular C++ data pointer. These are the top rated real world C++ (Cpp) examples of QSharedPointer::GetP2 extracted from open source projects. In my project I create QObject instances and give them a parent-child relationship. Example usage - #include <QSharedData> #include <QString> class EmployeeData : public QSharedData { public: EmployeeData() : id(-1) { }. std::shared_ptr. Also, this Q_DECLARE_METATYPE(SharedTestClass) shouldn't be needed. For instance, the method index returns a QModelIndex that takes a void pointer in the constructor, pointing to one of those. 1 Answer. This allows a safely shared pointer that can be used on objects that get passed around by reference like in C#. h","contentType":"file. the above one did not compile with msvc17 and with my arm toolchain. There are not so much Qt examples and demos with QSharedPointer because of the general concept for memory management in Qt using parent–child hierarchy of QObject. detach from the underlying data. The reference count for the new pointer is also printed. @Yakk: Thanks for that, I've updated my answer to reflect your point. append(QSharedPointer<MyObject>(new MyObject("second", 2))); Share. Also, this Q_DECLARE_METATYPE(SharedTestClass) shouldn't be needed. QSharedPointer Class Reference. A class derived from EmployeeData could override that function and return the proper polymorphic type. > > I hope this can help you. QSharedPointer<MyClass> mc (new MyClass ()); mc->testSharedThis (); QScopedPointer's second template parameter can be used for custom cleanup handlers. Usually one creates containers on the stack though, creating them on the heap is unidiomatic and unnecessary in almost all. But I've not seen it much in use in source code of Examples and Demos. 5. Detailed Description. 5 Note This class or function is reentrant. Like its name indicates, the pointer value is shared among all instances of QSharedPointer and QWeakPointer. QScopedPointer is a small utility class that heavily simplifies this by assigning stack-based memory ownership to heap allocations, more generally called resource acquisition is initialization (RAII). 详细描述. Example: QPointer < QLabel > label = new QLabel ; label - > setText( "&Status:" );. The latter is almost a drop-in replacement for the former, except that you can’t pass a QSharedPointer to QObject::connect. 1 Answer. That said, your stack trace is really strange:. QSharedPointer guarantees that the object isn't deleted, so if you obtain a non-null object, you may use the pointer. Detailed Description. @xylosper said in How to manage QObject instance which is shared among lots of C++/QML places:. It doesn't do any owning duties. As reference the example tested on cross environment using GDB:Here is a minimal example: #include <QSharedPointer> struct A {}; int main(int argc, char *argv[]) { auto ca = QSharedPointer<const A>::create(); return 0; } Here is one file (not minimal) example but with few working cases, 2 not working and a debug. example, this allows calling QObject::deleteLater() on a given object. > Regards, > > Alex > > > Rudenko Eugene a écrit : >> Hello. Qt Code: Switch view. See QWeakPointer::toStrongRef() for an example. The key point is that the technique of just returning QSharedPointer<T>(this) cannot be used, because this winds up creating multiple distinct QSharedPointer objects with separate reference counts. In many cases, that UB may be innocuous, but it is UB regardless. e. bool operator== ( const QSharedPointer & ptr1, const QSharedPointer & ptr2 ) Returns true if the pointer referenced by ptr1 is the same pointer as that referenced by ptr2. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. C++ (Cpp) QSharedPointer Examples. These are the top rated real world C++ (Cpp) examples of QSharedPointer::update extracted from open source projects. Modifying the data in the container will then affect all curves that share the container. Detailed Description. 1009. Neither of your approaches is thread-safe. Example: QPointer < QLabel > label = new QLabel ; label - > setText( "&Status:" );. As a iOS developer, I use a kind of smart pointers with reference counting implemented in NSObject whereby Im able to retain and release pointers when needed. There seems to be two ways to add data to a QCustomPlot graph, either you use data stored in a QVector or you use one these QSharedPointer to a. Show Hide. QSharedPointer has no knowledge about that incident and will not set the pointer to 0 automatically. These are the ownership "universes" (unless I'm mistaken): 1) Objects created in C++ owned via the QObject parent/child tree. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. The QWeakPointer is an automatic weak reference to a pointer in C++. If this function can determine that the pointer has already been deleted, it returns nullptr . QPointer:: QPointer () Constructs a guarded pointer with value nullptr. Yes. Of course, I want object to be deleted, But I want to assure, that only QShraredPointer can do it. QWeakPointer also provides the QWeakPointer::data () method that returns the tracked pointer without ensuring that it remains valid. For some reason, there are very few examples out there on how to use QSharedPointer, so i find myself posting here. See the typdefs Promise::Ptr, Deferred::Ptr etc. QSharedPointer<QMap<int, bool>> mpsptr = QSharedPointer<QMap<int, bool>>::create (QMap<int, bool> { {1, false}}); Ok, I found an answer that works for me. . 5. Documentation contributions included herein are the copyrights of their respective owners. Also, by overloading the operator, it's very easy to. no known conversion for argument 1 from 'const RecordPtr {aka const QSharedPointer<MyApp::Record>}' to 'const QObject*' you are trying to pass an object of type RecordPtr to a method expecting "const QObject*". You can also use a data stream to read/write raw unencoded binary data. : QFrame: Supports the box model. It is a bug if you put just a pointer to your item to QChache and at the same time such pointer is managed by QSharedPointer. In all other cases an invalid. Example. [/quote] That is a good example to be careful with smart pointers. You can use this constructor with any QObject, even if they were not created with QSharedPointer. ) summary refs log tree commit diff statsIn summary, you would need to go through the constructor and operator= as follows: Qsharedfoo = QSharedPointer<T> (rawfoo); // operator= () overload. Of course this can be extended with more tags such as "sample:" if you want to collect many different sets of data at once. 8. A typical application of this ticker is to make an axis only display integers, by setting the. removeAll(dataPoint01); }. It has all the features you may want in a modern pointer class: it is polymorphic, it supports static, const, and dynamic casts, it implements atomic reference-counting and thread-safe semantics, it supports. In this installment, we will look at how to use Open Asset Import Library (Assimp) (1) to load 3D models from some common 3D model formats. C++ (Cpp) QSharedPointer::isSelected - 12 examples found. Note that if you intend to use the type in queued signal and slot connections or in QObject's property system, you. See full list on doc. . I was reading about QSharedPointer in Qt. Several of the example programs connect the valueChanged() signal of a QScrollBar to. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. During program run cycle, DataVec is filled with. Most of the time it will just work in Qt because most of the time Qt objects have a parent which will handle deletion of children when destroyed. It cannot be used to dereference the pointer directly, but it can be used to verify if the pointer has been deleted or not in another context. ) method. Looking for examples of natural languages with affricates but no corresponding fricatives/plosivesMember Function Documentation QSharedPointer < T > QEnableSharedFromThis:: sharedFromThis (). A base class that allows obtaining a QSharedPointer for an object already managed by a shared pointer. A guarded pointer, QPointer<T>, behaves like a normal C++ pointer T *, except that it is automatically cleared when the referenced object is destroyed (unlike normal C++ pointers, which become "dangling pointers" in such cases). It behaves exactly like a normal pointer for normal purposes, including respect for constness. QSharedPointer will delete the pointer it is holding when it goes. It is a generic issue that you cannot have different owners of a pointer that do not know each. When the code block containing ptr2 ends, its reference. other. C++ (Cpp) QSharedPointer::direction - 6 examples found. The one I used in my own answer does. This works actually quite well (with some restrictions you have to have in mind). template <typename InputIterator>. QPointer is not a smart pointer. The object guarded by QSharedPointer is meant to be deleted by QSharedPointer itself when all owners go out of scope. These are the top rated real world C++ (Cpp) examples of QSharedPointer::isSelected extracted from open source projects. It is non-owning. As reference the example tested on cross environment using GDB:zar. The shared pointer will automatically destroy its contents only when there are no shared pointers referencing the object originally created for the shared pointer. const T *QSharedDataPointer:: constData const The connection in question is queued. For QSharedPointer . This function was introduced in Qt 5. All of QList's functionality also applies to QQueue. LcdNumber uses it, as the code above indicates, to set the displayed number. Maybe it is a proper thing to add some C++14-style wrapper for creating QObjects like this: @ namespace Qt. The d pointer points to an object of this type. QSharedPointer < T > QEnableSharedFromThis:: sharedFromThis () If this (that is, the subclass instance invoking this method) is being managed by a QSharedPointer, returns a shared pointer instance pointing to this; otherwise returns a null QSharedPointer. Previously i had done this: Code: MyObject * object; // Subclass of QObject. Here be dragons! All Qt containers implement COW (Copy On Write). You can inherit this class when you need to create a QSharedPointer from any instance of a class; for instance, from within the object itself. It's possible that your first thread will execute the if statement, then the other thread will delete your label, and then you will be inside of your if statement and crash. If you have 2 separate threads that are doing. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. The QSharedPointer is an automatic, shared pointer in C++. C++ (Cpp) QSharedPointer::Count - 2 examples found. This being the case, you have two ways around the problem: 1) Provide a copy constructor (which you have done) 2) Provide a specialization of qMetaTypeConstructHelper that doesn't use the copy constructor: template <> void *qMetaTypeConstructHelper<ClassA> (const ClassA *) { return new ClassA (); } Share. The pointer ptr becomes managed by this QSharedPointer and must not be passed to another QSharedPointer object or deleted. QSharedPointer guarantees that the object isn't deleted, so if you obtain a non-null object, you may use the pointer. You can rate examples to help us improve the quality of examples. The following examples can all be compiled and run independently. QSharedPointer, like QScopedPointer, is a smart pointer that deletes its referenced object, but copies are permitted, and the QSharedPointer keeps a reference count. T must be a subclass of QObject. [/quote] That is a good example to be careful with smart pointers. The example will output 1, 2, 3 in that order. id), name(other. Each QCPAxis has an internal QCPAxisTicker (or a subclass) in order to generate tick positions and tick labels for the current axis range. It is not possible to directly use static_cast, const_cast, dynamic_cast and reinterpret_cast on std::shared_ptr to retrieve a pointer sharing ownership with the pointer being passed as argument. If you want to actually delete a mutex, you have to remove it from the mutexes mapping. QSharedPointer will attempt to perform an automatic t static_cast. The examples on Wikipedia makes no sense to me. QList<T> is one of Qt's generic container classes. Detailed Description. Re: Custom Deleter for QSharedPointer.