I am trying to set a value inside a qlist of another qlist.

the code below gives me an error of ASSERT failure in QList<T> :: operator[] : "index out of range" .

main.hh
Qt Code:
  1. struct Order{
  2. QList<OrderItem> items ;
  3. }
  4.  
  5. struct OrderItem{
  6. QString Address;
  7. }
  8.  
  9.  
  10. main.cpp
  11.  
  12. Ordergroup *ordergroup ;
  13. QList<Order> orderlist;
  14. for (int i = 0; i <3 ; ++i) {
  15. for (int j =0 ; j < 3 ; ++j){
  16. if ( i == j){
  17. auto& refgr = orderlist[i];
  18. refgr.items[j].set(OrderItem::Address, "21 Street") ;
  19. }
  20. }
  21. }
To copy to clipboard, switch view to plain text mode 

I also tried the append but still it gives me an error of out of range.
If i set the the orderlist[i] into 1. it works but i need a set of arrays.
thanks in advance.