- 
    Bug 
- 
    Resolution: Invalid
- 
     Not Evaluated Not Evaluated
- 
    None
- 
    6.2.2
- 
    None
When activating a layout which has been built with layout items, but with non-contiguous indexes, qt will crash.
This issue includes a project that demonstrates the problem.
The following source code illustrates the problem
CustomWidget::CustomWidget(QWidget *parent)
    : QWidget{parent}
{
    QHBoxLayout * l = new QHBoxLayout(this);
    l->setSpacing(0);
    // BUG: Without the following line, this code crashes in Qt6.
    // It does not crash in Qt5 and behaves as if there is a zero-size
    // empty space (much like the following line).
//    l->insertSpacing(0,0);
    l->insertWidget(1, new QLabel("foo", this));
    l->insertWidget(2, new QLabel("bar", this));
    // this will crash
    QSize s = l->sizeHint();
}
You can see that the line l->insertSpacing(0,0); is commented out. Without that line, Qt5 handles it just fine and Qt6 crashes. Uncommenting the line will fix it for both versions.