QList wrapper
- 
Hi, I would like to override QList. If I instantiate it for example with QString, I would write: QList<QString> and if I would like to use Pointer it would be QList<QString*>. So is there a chance that I could override QList, that an instantiation QList<QString> would work like QList<QString*>? I would ALWAYS like to store/work only with the pointers. Thanks! 
- 
Hi, I would like to override QList. If I instantiate it for example with QString, I would write: QList<QString> and if I would like to use Pointer it would be QList<QString*>. So is there a chance that I could override QList, that an instantiation QList<QString> would work like QList<QString*>? I would ALWAYS like to store/work only with the pointers. Thanks! @firen said in QList wrapper: So is there a chance that I could override QList, that an instantiation QList<QString> would work like QList<QString*>? I would ALWAYS like to store/work only with the pointers. No, and why do you need to store a pointer to a QString in a container? Happy memleaks... 
- 
Hi, I would like to override QList. If I instantiate it for example with QString, I would write: QList<QString> and if I would like to use Pointer it would be QList<QString*>. So is there a chance that I could override QList, that an instantiation QList<QString> would work like QList<QString*>? I would ALWAYS like to store/work only with the pointers. Thanks! 
- 
@firen 
 A template class ?template <class T> class PointerList : public QList<T*> { public: PointerList() : QList<T*>() {} ~PointerList() { qDeleteAll(this->begin(),this->end()); } private: Q_DISABLE_COPY(PointerList) };
- 
@mpergand That was my idea as well but didn*t work. maybe I did something wrong. I will try again. :-) I read about Q_DISABLE_COPY. Isn`t it mainly for QObject based types? @firen said in QList wrapper: I read about Q_DISABLE_COPY. Isn`t it mainly for QObject based types? If you want to copy PointerList <T> then you have to provide a proper copy operator, the one generated by the compiler will not work, therefore Q_DISABLE_COPY. 
- 
@mpergand That was my idea as well but didn*t work. maybe I did something wrong. I will try again. :-) I read about Q_DISABLE_COPY. Isn`t it mainly for QObject based types? 
- 
It looks like this now: template <class T> class CPtrListWrapper: public QList<T*> { using Item = T*; public: CPtrListWrapper(): QList(), m_bAutoDelete(false), m_pCurrentItem(nullptr) { } ~CPtrListWrapper() { } //I need to wrap an old Containerclass and want to replace it internally by QList and these is one of the original methods void insert(uint i, const T* d) // { QList::insert(i, d); }But this gives me an error C2664 if I try: bas::qtw::CPtrList<QString> m_q5List; const QString* pString = new QString("TEST"); m_q5List.insert(0, pString);The error is that he cannot convert "const QString *" in "QString *const &" 
- 
It looks like this now: template <class T> class CPtrListWrapper: public QList<T*> { using Item = T*; public: CPtrListWrapper(): QList(), m_bAutoDelete(false), m_pCurrentItem(nullptr) { } ~CPtrListWrapper() { } //I need to wrap an old Containerclass and want to replace it internally by QList and these is one of the original methods void insert(uint i, const T* d) // { QList::insert(i, d); }But this gives me an error C2664 if I try: bas::qtw::CPtrList<QString> m_q5List; const QString* pString = new QString("TEST"); m_q5List.insert(0, pString);The error is that he cannot convert "const QString *" in "QString *const &" @firen said in QList wrapper: But this gives me an error C2664 if I try: Please post the whole error, not just its id. 
 Also, show the declaration of m_q5List.
- 
@firen said in QList wrapper: But this gives me an error C2664 if I try: Please post the whole error, not just its id. 
 Also, show the declaration of m_q5List.
 


