Hi, I'm trying to iterate through a QList of structs and modify elements within the struct, but can't figure it out.

My header looks like this:
Qt Code:
  1. struct buttonsStruct
  2. {
  3. QWidget *w;
  4. };
  5.  
  6. QPushButton *m_fireButton;
  7. QPushButton *m_iceButton;
To copy to clipboard, switch view to plain text mode 

In my cpp file, create two struct objects and add them to a QList.
Qt Code:
  1. buttonsStruct b1 = {m_fireButton, "Fire", m_tabFire};
  2. buttonsStruct b2 = {m_iceButton, "Ice", m_tabIce};
  3.  
  4. QList<buttonsStruct*> buttonsQList;
  5. buttonsQList.append(&b1);
  6. buttonsQList.append(&b2);
To copy to clipboard, switch view to plain text mode 

I iterate through out each QList struct, creating a new QPushButton.

Qt Code:
  1. QMutableListIterator<buttonsStruct*> it(buttonsQList);
  2. while (it.hasNext())
  3. {
  4. buttonsStruct *bs = it.next();
  5.  
  6. bs->pb = new QPushButton(m_centralWidget);
  7. (bs->pb)->setGeometry(QRect(xpos, ypos, 85, 25));
  8. (bs->pb)->setText(bs->s);
  9. ...
  10. }
To copy to clipboard, switch view to plain text mode 

When I try to access m_fireButton, I get a crash, and checking the memory address, I get 0x0.

Isn't bs->pb the same address as m_fireButton or m_iceButton? I'm modifying my struct elements directly in the iterator, no?

I looked through the documentation and found QMutableListIterator::QMutableListIterator(QList<T > & list)

so the QList is passed by reference. I can't see where I went wrong here. Any help?