Ricardo_arg
21st March 2010, 07:19
i have problems when i try to use the iterator with a list an a custom class T. it seems that is out of scope.
this is an example that explains better my point.
include "t.h"
include <QList>
class p
{
public:
void my_function();
private:
QList<T> list;
}
in the implementation:
T::my_funcion()
{
QList<T>::iterator it;//here it seems to be the problem,, because i think this class P, isnt the main class
for(it=list.begin();it!=list.end();it++)
{
//at this time i an only avaible to do this
list.at(i).show();//where show() is an public function of the object T
}
//obviouslly the compiler show the message warning that is not right to do this
//thenn compiler doesnt do nothinhg and do not compile the program
}
the main intention is to declare a object that use the QList class an declare function to work whit this class in the main class
some help pleasa!!
this is an example that explains better my point.
include "t.h"
include <QList>
class p
{
public:
void my_function();
private:
QList<T> list;
}
in the implementation:
T::my_funcion()
{
QList<T>::iterator it;//here it seems to be the problem,, because i think this class P, isnt the main class
for(it=list.begin();it!=list.end();it++)
{
//at this time i an only avaible to do this
list.at(i).show();//where show() is an public function of the object T
}
//obviouslly the compiler show the message warning that is not right to do this
//thenn compiler doesnt do nothinhg and do not compile the program
}
the main intention is to declare a object that use the QList class an declare function to work whit this class in the main class
some help pleasa!!