Avoid out-of-bound accesses in Qt Quick example code

Task-number: QTBUG-36197

Change-Id: I5545c36a1ce9ea6c2451c92e0e79f65e5ab26c68
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>