What may be the cause of following error?
-
@ASSERT failure in QList<T>::at: "index out of range"@
-
I believe you are passing an index position that doesn't exist. I mean for example that your QList has only five elements and you are trying to access the sixth.
const T & QList::at ( int i ) const
Returns the item at index position i in the list. i must be a valid index position in the list (i.e., 0 <= i < size())
-
[quote author="Josué V. Herrera" date="1324275775"]I believe you are passing an index position that doesn't exist. I mean for example that your QList has only five elements and you are trying to access the sixth.
const T & QList::at ( int i ) const
Returns the item at index position i in the list. i must be a valid index position in the list (i.e., 0 <= i < size())[/quote]
ok thanks i will check it. -
Worth mentioning that you'll see mainly two behaviours with Qt containers (as for example QList):
- at() and operator[] asserts on invalid indices,
- value() does not assert on invalid indices, it returns a default-constructed value instead.
If you use both your code may or may not assert, depending on which method you use, even though your code causes acccess to an invalid index.
-
Watch out, operator[] does assert!
-