sogico
15th August 2012, 19:02
Hi all,
I am trying to fill a QList with structs of 2 elements. At first, I am doing it as in the Address Book Example in Qt Examples and Demostrations, like this:
QList<QPair<int,int>> listOfPairs;
QPair<int,int> pair(1,1);
listOfPairs.insert(0,pair);
The code compiles right but when I check the list listOfPairs it has wrong values and not the two ones I have inserted. I have also tried with the method append, and I get the same result. And I've tried also changing the list of QPair's to a list of structs defined as:
typedef struct mystruct
{
int m_a;
int m_b;
mystruct(int a, int b)
{
m_a = a;
m_b = b;
}
}mystruct;
QList<mystruct> listOfMyStructs;
mystruct str(1,1);
listOfMyStructs.insert(0,str);
But it does not work again.
What am I doing wrong?
Thank you!
I am trying to fill a QList with structs of 2 elements. At first, I am doing it as in the Address Book Example in Qt Examples and Demostrations, like this:
QList<QPair<int,int>> listOfPairs;
QPair<int,int> pair(1,1);
listOfPairs.insert(0,pair);
The code compiles right but when I check the list listOfPairs it has wrong values and not the two ones I have inserted. I have also tried with the method append, and I get the same result. And I've tried also changing the list of QPair's to a list of structs defined as:
typedef struct mystruct
{
int m_a;
int m_b;
mystruct(int a, int b)
{
m_a = a;
m_b = b;
}
}mystruct;
QList<mystruct> listOfMyStructs;
mystruct str(1,1);
listOfMyStructs.insert(0,str);
But it does not work again.
What am I doing wrong?
Thank you!