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
struct Order{
QList<OrderItem> items ;
}
struct OrderItem{
}
main.cpp
Ordergroup *ordergroup ;
QList<Order> orderlist;
for (int i = 0; i <3 ; ++i) {
for (int j =0 ; j < 3 ; ++j){
if ( i == j){
auto& refgr = orderlist[i];
refgr.items[j].set(OrderItem::Address, "21 Street") ;
}
}
}
struct Order{
QList<OrderItem> items ;
}
struct OrderItem{
QString Address;
}
main.cpp
Ordergroup *ordergroup ;
QList<Order> orderlist;
for (int i = 0; i <3 ; ++i) {
for (int j =0 ; j < 3 ; ++j){
if ( i == j){
auto& refgr = orderlist[i];
refgr.items[j].set(OrderItem::Address, "21 Street") ;
}
}
}
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.
Bookmarks