I am using the FlowLayout custom layout example, with one small modification, inside a QScrollLayout.

The custom modification is that I'm adding a 'insertWidgetAt' function (alongside the normal 'addWidget' function), but try as I might, I can't seem to get the inserted widget to display.
Qt Code:
  1. void FlowLayout::insertWidgetAt(QWidget *widget, int index)
  2. {
  3. this->itemList.insert(index, new QWidgetItem(widget));
  5. //What function do I need to call here, to make the inserted widget show up?
  6. }
To copy to clipboard, switch view to plain text mode 

I've tried:

And: (from the Qt FlowLayout example)
doLayout(QLayout::geometry(), false);
doLayout(QRect(0, 0, 0, 0), false);

Calling the regular customLayout->addWidget() works fine. The customLayout->insertWidgetAt() never shows up, even if I call addWidget() afterward.

My guess at the problem: I never inform the QScrollArea of the widget... only the QScrollArea's layout. Does the layout somehow inform the parent widget of added widgets? How is my custom layout supposed to do that?

QLayout::addWidget() calls the FlowLayout::addItem(). Clearly something happens in QLayout::addWidget() that is significant, that I'm not aware of. I've looked in the Qt source, but I can't find the QLayout source file.
I've also looked at QBoxLayout::insertWidgetAt() source code, and it doesn't seem to be doing anything special, though I can't be sure because of the heavy use of unfamiliar macros.