PDA

View Full Version : Find item index in QGraphicsLinearLayout



bmn
22nd May 2014, 08:32
How i can find item index in QGraphicsLinearLayout, like findWidget in QLayout? And how i can remove stretch?

d_stranz
23rd May 2014, 00:06
Write your own findItem:



int findItem( QGraphicsLinearLayout * pLayout, QGraphicsItem * pItem )
{
for ( int nItem = 0; nItem < pLayout->count(); ++nItem )
if ( pItem == pLayout->itemAt( nItem )->graphicsItem() )
return nItem;
return -1;
}


As for removing stretch, I suppose it occupies an index in the QGraphicsLinearLayout, so QGraphicsLinearLayout::removeAt() should do it.