Something wrong with pointer I think
-
Hi,
Here is my code :@
for(int i=0 ; i<8 ;i+=2)
{
QLabel *l = new QLabel(QString::number(i));
_codeAxe.append(l);
}
@_codeAxe is :
@QVector<QLabel*> _codeAxe;@I dont understand why all QLabel into _codeAxe have the same pointer ?
exemple of result of Qdegub:
QVector(QLabel(0x12fd1390) , QLabel(0x12fd1390) , QLabel(0x12fd1390) , QLabel(0x12fd1390) , QLabel(0x12fd1390) , QLabel(0x12fd1390) , QLabel(0x12fd1390) ) -
The QDebug output you show does not seem to be in sync with the code you pasted. In your code, the for-loop would be executed four times but your debug output shows seven elements.
What happened there?A general notel, there is no need to go complex, just use this:
@_codeAxe.append(new QLabel(QString::number(i));@
~ Tectu
-