C++ (Cpp) QSharedPointer::update - 7 examples found. QPointer is not a smart pointer. In that case, I think you need to register them. list. The title can be styled using the. I use C++17, GCC 7. template<class T> QSharedPointer<T> I checked a bit on StackOverflow but others examples are really complicated. The normal pattern is to put the new statement inside the smart pointer's constructor, like this: QSharedPointer<Obj> p (new Obj (2)); That way you never have a reference to the naked pointer itself. That said, your stack trace is really strange:. It behaves exactly like a normal pointer for normal purposes, including respect for constness. 1011. The following custom cleanup handlers exist: QScopedPointerDeleter - the default, deletes the pointer using delete. See QWeakPointer::toStrongRef() for an example. behaves exactly like a normal pointer for normal purposes, including respect for constness. template parameter is not a base or a derived type from. In this guide, we will discuss the differences between QSharedPointer and QSharedDataPointer and show code examples. ) method. A base class that allows obtaining a QSharedPointer for an object already managed by a shared pointer. The QSharedPointer class holds a strong reference to a shared pointer The QSharedPointer is an automatic, shared pointer in C++. I would still recommend you to use 2/3, as. However, if the string contains non-numeric characters, it cannot be converted to an integer, and any attempt to convert it will fail. I see that QSharedPointer keeps my data valid if the acquisition threads stop during data is processing. The exception is pointers derived from QObject: in that. Detailed Description. Immediately after construction both pointers go out of scope. 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. h","path":"src/corelib/tools/qalgorithms. data(); delete obj; To copy to clipboard, switch view to plain text mode. This project implements the Event and BlockingQueue in two. , a reference counter placed outside the object). h","contentType":"file. 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). Since display() is part of the class's interface with the rest of the program, the slot is public. Navigation. A smart pointer is an abstract data type that has all features of a standard pointer and additionally provides automatic garbage collection. Purpose. Maybe I have bad expressed. 1 Creates a QSharedPointer object and allocates a new item of type \tt T. I was reading about QSharedPointer in Qt. @xylosper said in How to manage QObject instance which is shared among lots of C++/QML places:. One problem i have ran into is using signals and slots with the objects that are shared-pointed-to. 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. When removeData() returns, any further attempts to reference the sender is undefined behavior. You might be tempted to use QSharedPointer in this case and it would work, but remember that QSharedPointer, just like std::shared_ptr, is a lot heavier construct, as sharing in a multi-threaded world is a "far from 0" overhead thing. 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. When the code block containing ptr2 ends, its reference. A class derived from EmployeeData could override that function and return the proper polymorphic type. Detailed Description. Returns a const pointer to the shared data object. QSharedPointer is Qt's own "smart pointer" to shared data, similar to. QSharedPointer. That said, your stack trace is really strange:. The content is extracted recursively to a temporary folder. If the reference count is zero then the object it is pointing to will be destroyed. It doesn't do any owning duties. e. Make a typedef for QSharedPointer<UserDataType>, and use both Q_DECLARE_METATYPE as well as qRegisterMetaType () to register it for use. 1 Reply Last reply . Adding a Q_DECLARE_METATYPE () makes the type known to all template based functions, including QVariant. Like its name indicates, the pointer value is shared among all instances of QSharedPointer and QWeakPointer. Most of the time it is not a good idea to use raw pointers (in modern C++). The problem is, that when implementing a QSharedAbstractItemModel, like the QAbstractListModel, you need to deal with raw pointers. MyObject * obj = sharedPointerToObject. [noexcept] const T *QSharedDataPointer:: constData const. If you refactor your code so that all new operator are in lines like these, all your problems will be solved. Now I have a situation in which a class has to call a function and pass a pointer to itself. 209: The pointer to the object is kept here because it needs to match the actual: 210: deleter function's parameters, regardless of what template argument the: 211: last QSharedPointer instance had. Also, this Q_DECLARE_METATYPE(SharedTestClass) shouldn't be needed. QWeakPointer objects can only be created by assignment from a QSharedPointer. QSharedPointer<QMap<int, bool>> mpsptr = QSharedPointer<QMap<int, bool>>::create (QMap<int, bool> { {1, false}}); Ok, I found an answer that works for me. View QSharedPointer. Detailed Description. QGroupBox: Supports the box model. This QCPAxisTicker subclass generates ticks with a fixed tick step set with setTickStep. It is non-owning. Detailed Description. class QSharedPointer< T > The QSharedPointer class stores a pointer to a potentially shared object. Study Resources. 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. Your solution is simple. 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. Copy assigns from other and returns a reference to this object. The example below illustrates that it works in both single- and multi-threaded cases, and then reproduces. In that case, I think we should pass by reference. That said, your stack trace is really strange:. This function was introduced in Qt 5. Args> QSharedPointer<T> QSharedPointer<T>::create(Args &&. To avoid the cost of thread creation, a thread pool can be used. The following chapters show an example and explain a few important details regarding the functionality and limits of the implementation. Aug 27, 2015 at 15:02. QSharedPointer<QMap<int, bool>> mpsptr = QSharedPointer<QMap<int, bool>>::create (QMap<int, bool> { {1, false}}); Ok, I found an answer that works for me. // Create a fresh shared pointer in the scope QSharedPointer<uint8_t> image(new uint8_t[IMG_SIZE]); // the ring buffer can possibly be rewritten on the next usb_read() (if bufferlength = 1) so I copy. When an object gets deleted, either by delete childObject; or delete parentObject;, I would like the QSharedPointer instances to return true when calling isNull(). 19. QSharedPointer. Examples at hotexamples. x. It is usually best to use a mutex with a QMutexLocker since this makes it easy to ensure that locking and unlocking are performed consistently. The application consists of the following steps: Download images form the list of URLs specified by the user. The reference count for the new pointer is also printed. 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). The pointed-to value in the Q_ASSERT will live until the statement finishes. These are the top rated real world C++ (Cpp) examples of QSharedPointer::getEndPoint extracted from open source projects. These are the top rated real world C++ (Cpp) examples of QSharedPointer::at extracted from open source projects. C++ (Cpp) QSharedPointer::clone - 13 examples found. It can deallocate the underlying implementation detail - the shared reference object, but that doesn't affect anything really that the user cares about; those objects are deallocated only when the. QSharedPointer 是一个 共享指针 ,它与 QScopedPointer 一样包装了new操作符在堆上分配的动态对象,但它实现的是引用计数型的智能指针 ,也就是说,与QScopedPointer不同的是,QSharedPointer可以被自由地拷贝和赋值,在任意的地方共享它,所以QSharedPointer也可以用作容器. It behaves exactly like a normal pointer for normal purposes, including respect for constness. C++ (Cpp) QSharedPointer::direction - 6 examples found. So a conclusion would be: watch out for run-away. MyObject * object; // Subclass of QObject. For instance, the method index returns a QModelIndex that takes a void pointer in the constructor, pointing to one of those. out of scope, provided no other QSharedPointer objects are. 이는 불변성에 대한 존중을 포함하여 일반적인 목적을 위한 일반 포인터와 똑같이 동작합니다. Show the scaled images in a grid layout. GetInfo(9) GetRemoteId(8) AddChildren(5). example, this allows calling QObject::deleteLater() on a given object. In your case, you are letting QMainWindow to delete cV when user closes it. So it this allows multiple pointers to point to the same class instance. When removeData() returns, any further attempts to reference the sender is undefined behavior. If this function can determine that the pointer has already been deleted, it returns nullptr. But I've not seen it much in use in source code of Examples and Demos. These are the top rated real world C++ (Cpp) examples of QSharedPointer::direction extracted from open source projects. A QSharedPointer object can be created from a. It is similar to std::shared_ptr in C++. The problem is that this code is creating a QSharedPointer from a raw pointer, which implies ownership of the object pointed to. [quote author="situ117" date="1304279927"] I was reading about QSharedPointer in Qt. しかし、Qtを使っている場合は、わざわざ自分でMutexの管理をしなくても、スレッドとのデータのやり取りを全て signal/slotでやってしまい、共有データを. This is a working example showing it calls. QSharedPointer IF you using a pointer and start giving pointer to other functions and you are passing your pointer all over. When I try to simply connect signalslot with such QVector as argument programm tells during run that this metatype should be registered (though QVector, QSharedPointer and class inherited from QObject should be registered automatically. Assume that we have T convert_func (const QJsonValue& value),. Otherwise, the object deletes itself after emitting the signal. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. QScopedPointer guarantees that the object pointed to will get deleted when the current scope disappears. staticCast<Switch> (); Both versions are basically equivalent to doing static_cast on raw pointers. I want QSharedPointer nav = m->getINav (); to be in while loop itself as this is kind of dummy application for my real. h in my header file code like : But when I start using QSharedPointer, and I have to use the traditional way, which means u have to include its . Qt Code: Switch view. One problem i have ran into is using signals and slots with the objects that are shared-pointed-to. For example, you can use isEmpty() to test whether the queue is empty, and you can traverse a QQueue using QList's iterator classes (for example, QListIterator). The QSharedPointer is an automatic, shared pointer in C++. The item object can be destroyed by QSharedPointer destructor, so QChache will have invalid pointer. One problem i have ran into is using signals and slots with the objects that are shared-pointed-to. As a general guideline, if you are not sharing your pointers between multiple users, use a QScopedPointer, otherwise use a QSharedPointer. The problem is that this code is creating a QSharedPointer from a raw pointer, which implies ownership of the object pointed to. QPointer:: QPointer () Constructs a guarded pointer with value nullptr. qRegisterMetaType< QSharedPointer<TestClass> >("SharedTestClass"); in main() not as a global variable. Since a QSharedPointer is used, multiple QCPGraphs may share the same data container safely. Commented defines are for "not compiling" parts. Smart pointers with PythonQt. QSharedPointer has no knowledge about that incident and will not set the pointer to 0 automatically. File: searchtrackmodel. cpp Project: Samt43/QmlMusicPlayerUIQSharedPointer guarantees that the object isn't deleted, so if you obtain a non-null object, you may use the pointer. There are several ways to avoid the problem in this particular example I can think of: change Test destructor to expect null m, write template template<typename T> inline T no_move (T&& tmp) {return tmp;}, explicitly create temporary Test object in assign, add getter for m and call it to force copying m (advised by Jarod42 ); MS Visual Studio. For example, using data() for QObject::connect() would be save, but. args) \overload \since 5. 1 Creates a QSharedPointer object and allocates a new item of type t T. The interface: Model. However, by that time, a. Smart pointers on the other hand, is more a category than a specific type, including shared pointers, auto. [noexcept] const T *QSharedDataPointer:: constData const. Detailed Description The QSharedPointer class holds a strong reference to a shared pointer The QSharedPointer is an automatic, shared pointer in C++. Example: QPointer < QLabel > label = new QLabel ; label - > setText( "&Status:" );. QCborMap::Iterator class provides an STL-style non-const iterator for QCborMap. Equivalent to: QSharedPointer<T> other(t); this->swap(other); Resets this QSharedPointer object to point to t instead, with the Deleter deleter. Simple CBOR stream decoder, operating on either a QByteArray or QIODevice. 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. Depending on your use case that might be a better. Commented defines are for "not compiling" parts. QSharedPointer is a smart. to ensure that the pointers being compared are equal. Here is an example: @ // sender class class A : public QObject {Q_OBJECT public: void test() {QSharedPointer<Data> dataPtr = QSharePointer<Data>(new Data());. Since the replicas have the same properties, signals, and slots as were. or if you already have a reference to a pointer, then use the reset () method as follows: Qsharedfoo. What I did: @APIRequest::APIRequest () {. For example, when saving the plot to disk. But in addition, QQueue provides three convenience functions. This function was introduced in Qt 4. A class derived from EmployeeData could override that function and return the. Children are typically added to a QObject *parent from their constructor with new QObject(parent);. example, this allows calling QObject::deleteLater() on a given object. Examples and Tutorials Supported Platforms What's new in Qt 6 Qt Licensing Overviews Development Tools User Interfaces Core Internals. #include "employee. Instead, the functions std::static_pointer_cast, std::const_pointer_cast, std::dynamic_pointer_cast and std::reinterpret_pointer_cast. class SomeClass { SomeClassP getInstance () { return SomeClassP (new SomeClass ()); } } typedef. AnotherObject * something; The c++ (cpp) qsharedpointer example is extracted from the most popular open source projects, you can refer to the following example for usage. For QSharedPointer . QSharedPointer guarantees that the object isn't deleted, so if you obtain a non-null object, you may use the pointer. e. The problem of owner ship of the memory is avoided. These are the top rated real world C++ (Cpp) examples of QSharedPointer::GetCenter extracted from open source projects. All of QList's functionality also applies to QQueue. Qt Base (Core, Gui, Widgets, Network,. However, when I try to debug using GDB, the debugger receives segmentation faults. std::shared_ptr<Exercise> americanExercise = std::make_shared<AmericanExercise> (settlementDate, in. centralwidget = std::make_shared<QWidget> (MainWindow); verticalLayout = std::make_shared<QVBoxLayout> (centralwidget. Modifying the data in the container will then affect all. MyObject * object; // Subclass of QObject. These conversions are called in a shared object which is properly loaded at runtime. The requester class should also be in charge of managing the memory of the pointer it created. 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. 1010. These are the top rated real world C++ (Cpp) examples of QSharedPointer::node extracted from open source projects. out of scope, provided no other QSharedPointer objects are. Ah, when the function actually needs to manipulate the smart pointer itself. So QSharedPointer was shelved for 4. Maybe it is a proper thing to add some C++14-style wrapper for creating QObjects like this: @ namespace Qt. qRegisterMetaType< QSharedPointer<TestClass> >("SharedTestClass"); in main() not as a global variable. . h file like: #include "myclass. 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. 04: class QSharedPointer<VideoItemPrivate> has no member named ‘get’ Hello everyone, I'm trying to install gst-plugins-good 1. . Use qSharedPointerCast (): QSharedPointer <Switch> mySwitchTest= qSharedPointerCast<Switch> (myState); Or call staticCast () on the smart pointer: QSharedPointer <Switch> mySwitchTest= myState. You will need to delete it yourself: ~MyClass () { delete m_process. In many cases, that UB may be innocuous, but it is UB regardless. 4. And most of QObjects are created with raw new operations. Also, by overloading the operator, it's very easy to. A more complex program sending QSharePointer objects using slots has a similar situation with GDB, that can be reproduced with the previous example. 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. These are the top rated real world C++ (Cpp) examples of QSharedPointer::update extracted from open source projects. The QSharedPointer is an automatic, shared pointer in C++. >> I'm trying to use QMap/QHash with QSharedPointer with no success. Also my first approach produces a memory leak. Combining this with QSharedPointer for example might result in multiple object free or access after free kind of problems. For some reason, there are very few examples out there on how to use QSharedPointer, so i find myself posting here. QQueue inherits from QList. Here be dragons! All Qt containers implement COW (Copy On Write). See also append() and insert(). In my project I create QObject instances and give them a parent-child relationship. I would still recommend you to use 2/3, as recommended by Benjamin. Example: QPointer < QLabel > label = new QLabel ; label - > setText( "&Status:" );. Programming Language: C++ (Cpp) Class/Type: QSharedPointer. h" int main(). qRegisterMetaType< QSharedPointer<TestClass> >("SharedTestClass"); in main() not as a global variable. data());@ Then I have a number of SLOTS connected to this SIGNAL. It stores its items in adjacent memory locations and provides fast index-based access. 5. I use elements of the list by creating a new (not a keyword) QSharedPointer<MyClass> newPointer = list. It has a concept of ownership. These are the top rated real world C++ (Cpp) examples of QSharedPointer::UpdateViewSection extracted from open source projects. wysota. A simple code that could reproduce the issue. For instance, the method index returns a QModelIndex that takes a void pointer. 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. There is a QList member variable named m_noteList containing QSharedPointer elements of class Note. QSharedPointer holds a shared pointer by means of an external reference count (i. com: 30. The example above tests that mkdir() outputs the right warning when invoked with an invalid file name. But in addition, QQueue provides three convenience functions. The reference count for the new pointer is also printed. These are the top rated real world C++ (Cpp) examples of QSharedPointer::GetP2 extracted from open source projects. Creating and destroying threads frequently can be expensive. Having said that, without a perfect forwarding, using this function may be inefficient. g. You can use smart pointers to hold you item in your QList, for example QSharedPointer<MyCustomObj>. qRegisterMetaType< QSharedPointer<TestClass> >("SharedTestClass"); in main() not as a global variable. Make sure you don’t call delete on the objects. See Customizing QDockWidget for an example. These are the top rated real world C++ (Cpp) examples of QSharedPointer::Count extracted from open source projects. You can rate examples to help us improve the quality of examples. docx from EEET 1026 at University of South Australia. If you look at the function definition, you'll see there is just one version : bool QMetaObject::invokeMethod ( QObject * obj, const char * member, QGenericArgument val0 = QGenericArgument ( 0 ), QGenericArgument val1 = QGenericArgument (), QGenericArgument val2 = QGenericArgument (),. Qt로 프로그래밍할 때 메모리 관리 문제 (메모리 관리 불량으로 인한 메모리 누수 및 버그. You can rate examples to help us improve the quality of examples. A class derived from EmployeeData could override that function and return the proper polymorphic type. These are the top rated real world C++ (Cpp) examples of QSharedPointer::isSelected extracted from open source projects. 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. Programming Language: C++ (Cpp) Class/Type: QSharedPointer. You can rate examples to help us improve the quality of. Are QSharedPointer in general designed to be passed through signals that way? And if so, is there a mecanism to keep a reference while it is queued? I considered the folowing solutions, but I'm not totally fine with neither of them:. Using lambdas as slots is straightforward (for example for an event from a QSpinbox): connect (spinboxObject, &QSpinBox::editingFinished, this, [this] () {<do something>}); But this works only if the signal is not overloaded (that means there are several signals with the same name but different arguments). to ensure that the pointers being compared are equal. QSharedPointer will delete the pointer it is holding when it goes. But indeed Qt is leaking the functor object. Qt provides a number of thread synchronization constructs, you'll probably want to start with QMutex and learn more about thread-safety. In this video series we will cover Qt 6. ) default. I know that QVector is calling destructors for it's objects, that he is holding. However, upon deleting. So QSharedPointer was shelved for 4. QSharedPointer:: QSharedPointer (const QWeakPointer < T > &other) Creates a QSharedPointer by promoting the weak reference other to strong reference and sharing its pointer. It works like variables in Java and CPython, or like std::shared_ptr. 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. The QSharedPointer class holds a strong reference to a shared pointer. Good day QT'ers, wondering if there's a better way to remove a QSharedPointer from a QList loaded with them. QSharedPointer will delete the pointer it is holding when it goes out of scope, provided no other QSharedPointer objects are referencing it. The application is working as expected (creating and destroying the objects). QPointer:: ~QPointer () Destroys the guarded pointer. C++ (Cpp) QSharedPointer::at - 10 examples found. When the last associated QSharedPointer goes out of scope, the object will be deleted. 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. You can rate examples to help us improve the quality of examples. Qt 6 youtube videos by Bry. For example, you can use isEmpty() to test whether the queue is empty, and you can traverse a QQueue using QList's iterator classes (for example, QListIterator). The base class of all event classes. behaves exactly like a normal pointer for normal purposes, including respect for constness. other. So a conclusion would be: watch out for run-away. Member Function Documentation QPointer:: QPointer (T *p) Constructs a guarded pointer that points to the same object that p points to. On programm exit i have 2 destructor calls for GeTokenItem and one more that invokes acces violation. staticCast<Switch> (); Both versions are basically equivalent to doing static_cast on raw pointers. These are the top rated real world C++ (Cpp) examples of QSharedPointer::isNull extracted from open source projects. I worked around this by extracting a raw pointer from the QSharedPointer: The template parameter is the type T of the class which QSharedPointer tracks. . . h","path":"src/corelib/tools/qalgorithms. 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*". h","contentType":"file. This function was introduced in Qt 5. I have a problem with QSharedPointer and QVector in this lines of my code: If tokencount == 2. Here comes an example using Event (The complete code is in the event_example directory). When the last associated QSharedPointer goes out of scope, the object will be deleted. QSharedPointer will attempt to perform an automatic t static_cast. Note that if you intend to use the type in queued signal and slot connections or in QObject's property system, you also have to call. C++ (Cpp) QSharedPointer::isSelected - 12 examples found. The code below won't leak memory and doesn't invoke any undefined behavior. LcdNumber uses it, as the code above indicates, to set the displayed number. at (x); Then I pass it around and do the work, then the pointer dies but I have an extra one in the list so everything's fine, right? I noticed the destructor of MyClass is. QSharedPointer will delete the pointer it is holding when it goes. 2 Answers Sorted by: 4 You can create a custom connect function: template<class T> bool my_connect (const QSharedPointer<T> &sender, const char. It behaves exactly like a normal pointer for normal purposes, including respect for constness. In the example above, the template specialization for the clone() function calls the EmployeeData::clone() virtual function. get ()); Have a look at the documentation of std::make_shared (for example here ). Show Hide. QScopedPointerArrayDeleter - deletes the pointer using delete []. #include <QWidget> #include <QSpinBox> class MyWidget : QWidget // A template widget to be placed in MainWindow { Q_OBJECT public: MyWidget () { this->spinBox = new. qRegisterMetaType< QSharedPointer<TestClass> >("SharedTestClass"); in main() not as a global variable. 1 Answer. A base class that allows obtaining a QSharedPointer for an object already managed by a shared pointer. QList<T> and QVarLengthArray<T> provide similar APIs and functionality. So a conclusion would be: watch out for run-away. > > I hope this can help you. Also, this Q_DECLARE_METATYPE(SharedTestClass) shouldn't be needed. Their main advantage is reducing memory leaks and bugs due to poor memory management. Example#1. 1009. 212: 213: This class is never instantiated directly: the constructors and: 214In the example above, the template specialization for the clone() function calls the EmployeeData::clone() virtual function. You can use this constructor with any QObject, even if they were not created with QSharedPointer. It behaves exactly like a normal pointer for normal purposes, including respect for constness. Unfortunately Google was unable to help me this time. This example shows how to use the QFuture, QPromise, and QFutureWatcher classes to download a collection of images from the network and scale them, without blocking the UI. QSharedPointer:: objectCast() works reliably across DLL boundaries, but QSharedPointer:: dynamicCast() and std::dynamic_pointer_cast() don’t. QPointer is a tracking pointer. I also want to keep track of some of the objects with QSharedPointer instances. QSharedPointer:: objectCast() works reliably across DLL boundaries, but QSharedPointer:: dynamicCast() and std::dynamic_pointer_cast() don’t. T *QWeakPointer:: data const. I have QList<QSharedPointer<MyClass>>. Also if you had been used raw pointers in QList it would not work because you can not overwrite the == operator of the raw pointer (you. The QCPGraphDataContainer is an abstract data container of QCPGraphData object, one of which will be created for each data point that we parse. One example may be the case where you store lots of pointers to objects in a container class. In short - an atomic operation is one that is so "small" (hence the name) that it cannot be interrupted (for example by another thread) and therefore is thread-safe. Modifying the data in the container will then affect all curves that share the container. How can I register, for example, QSharedPointer< int > in meta type system.