title: How to add an Item to the specific index in the layout
body: <p>I am following this example to create a Flow layout:</p>
  
  <p><a href="http://doc.qt.io/qt-4.8/qt-layouts-flowlayout-example.html" rel="nofollow">http://doc.qt.io/qt-4.8/qt-layouts-flowlayout-example.html</a></p>
  
  <p>This doesn't have <code>addToIndex(int _index)</code> function, so I would like to implement this. Since this layout uses QLayoutItems, I would like to create a function which can insert an Item after the specific index.</p>
  
  <p>How can I get the index of an Item as integer and insert to the layout?</p>
  
  <p>UPDATE:</p>
  
  <p>flowlayout.cpp</p>
  
  <pre><code>FlowLayout *flowLayout = new FlowLayout;
  void FlowLayout::insertItem(int index, QLayoutItem *item) 
  {
     if(itemList.size() &lt; index)
     {
       itemList.append(item);
     }
     else
     {
       itemList.insert(index,item);
       QRect tmp = this-&gt;geometry();
     }
     update();
  }
  </code></pre>
  
  <p>flowwindow.cpp</p>
  
  <pre><code>void FlowWindow::addLineBreak()
  {
  
    flowbreak = new FlowLayoutButton(NULL);
  
    QLayoutItem *item = new QWidgetItem(flowbreak);
    flowlayout-&gt;insertItem(index, item);
    //flowlayout-&gt;addWidget(flowbreak);
  
  }
  </code></pre>
  
  <p>flowlayoutbutton.cpp constructor</p>
  
  <pre><code> FlowLayoutButton::FlowLayoutButton(QWidget *_parent):QWidget(_parent)
   {
    QBoxLayout *layout = new QHBoxLayout;
  
  
    flowbreak = new QPushButton(tr("-------Label-------"));
    flowbreak-&gt;setGeometry(0, 0, 200,20);
    layout-&gt;addWidget(flowBreak);
  
    setLayout(layout);
  }
  </code></pre>