As of Qt6, QList will assert that an insertion index is in range of
existing values. QBoxLayout interprets negative indices as "append at
the end". That part is covered.
Indices larger than the number of items in the layout would trigger the
assertion in QList, but after the insert method had returned. That would
make it hard to debug. This change asserts the index range before
inserting, thus making it easier to spot the problem.
Fixes: QTBUG-103775
Change-Id: Ida099f785263fe8a5c8a1d0a48c4ff87713549b4
Pick-to: 6.2 6.3 6.4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>