In line 13 in your original code, you declare a QList named "orderlist". This is an empty list. In line 17, you try to access the item at index "i" in this list. Because the list is empty, there is no item at -any- index (including zero), so you get an out of range error.
Did you make a mistake and declare this "orderlist" as a local variable, and thereby maybe hide a member variable in your class with the same name that actually does have contents?
In any case, you should also follow anda_skoa's suggestion to use "orderlist.count()" as the terminator for your loop variable instead of a hard-coded "3".
Also, your loops over i and j don't make a lot of sense. You are executing the innermost loop 9 times (3 times 3 for i * j), but you are only doing something if i == j. You can get rid of the inner loop entirely, and move its code into the loop over i. Replace j with i and you get the same result.
Bookmarks