Qt-interest Archive, May 2007
qptrlist warning messages:
Message 1 in thread
hi,all
i got these messages when i use QPtrList
/usr/lib/qt/include/qptrlist.h: In member function 'void
QPtrList<type>::deleteItem(void*) [with type = myApp]':
myapp.cc:315: instantiated from here
/usr/lib/qt/include/qptrlist.h:150: warning: possible problem detected
in invocation of delete operator:
/usr/lib/qt/include/qptrlist.h:150: warning: invalid use of undefined
type 'struct myApp'
myappmainwindow.h:22: warning: forward declaration of 'struct myApp'
/usr/lib/qt/include/qptrlist.h:150: note: neither the destructor nor
the class-specific operator delete will be called, even if they are
declared when the class is defined.
what's the problem?
thanks
--
[ signature omitted ]
Message 2 in thread
> what's the problem?
What's the code?
Malte
--
[ signature omitted ]
Message 3 in thread
You have to include header file where myApp is declared before like 22
in myappmainwindow.h, where the variable of type QPtrList<myApp> is
declared.
Martin Petricek
On 5/10/07, jiang jefix <jefix214@xxxxxxxxx> wrote:
> hi,all
> i got these messages when i use QPtrList
>
> /usr/lib/qt/include/qptrlist.h: In member function 'void
> QPtrList<type>::deleteItem(void*) [with type = myApp]':
> myapp.cc:315: instantiated from here
> /usr/lib/qt/include/qptrlist.h:150: warning: possible problem detected
> in invocation of delete operator:
> /usr/lib/qt/include/qptrlist.h:150: warning: invalid use of undefined
> type 'struct myApp'
> myappmainwindow.h:22: warning: forward declaration of 'struct myApp'
> /usr/lib/qt/include/qptrlist.h:150: note: neither the destructor nor
> the class-specific operator delete will be called, even if they are
> declared when the class is defined.
>
> what's the problem?
> thanks
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]
Message 4 in thread
i do include <qptrlist.h>
both in .h and .cpp
my code skeleton:
myapp.h:
#include ....
#include <qptrlist.h>
class myAppMW;
class myApp{
..........
QPtrList<myAppMW> pl_mw;
//////////////////
myapp.cpp
#include <qptrlist.h>
#include "myappmainwindow.h" // define the class myAppMW
pl_mw.append( some thing );
...
//
regards
--
[ signature omitted ]
Message 5 in thread
jiang jefix wrote:
> i do include <qptrlist.h>
> both in .h and .cpp
>
> my code skeleton:
>
> myapp.h:
> #include ....
> #include <qptrlist.h>
>
Remove:
> class myAppMW;
Add:
#include "myappmainwindow.h"
>
> class myApp{
> ..........
> QPtrList<myAppMW> pl_mw;
>
> //////////////////
> myapp.cpp
> #include <qptrlist.h>
> #include "myappmainwindow.h" // define the class myAppMW
>
> pl_mw.append( some thing );
> ...
>
> //
>
>
> regards
As Martin already noted, you need to define myAppMW before using it in
QPtrList ... forward declaration is not enough.
--
[ signature omitted ]