QskLinearBox::spacingAtIndex added

This commit is contained in:
Uwe Rathmann 2019-07-09 14:27:50 +02:00
parent c1de001da4
commit 6838260606
4 changed files with 14 additions and 11 deletions

View File

@ -53,7 +53,7 @@ namespace
{ {
const int index = 0; const int index = 0;
QQuickItem* item = itemAtIndex( index ); auto item = itemAtIndex( index );
removeAt( index ); removeAt( index );
if ( item == nullptr ) if ( item == nullptr )

View File

@ -35,10 +35,7 @@ namespace
addRectangle( "FireBrick" ); addRectangle( "FireBrick" );
addRectangle( "DarkRed" ); addRectangle( "DarkRed" );
// setRowSpacing( 5, 30 );
insertSpacer( 5, 30 ); insertSpacer( 5, 30 );
// insertStretch( 5, 2 );
// setRetainSizeWhenHidden( 2, true );
} }
void mirror() void mirror()
@ -50,17 +47,16 @@ namespace
{ {
const int index = 0; const int index = 0;
QQuickItem* item = itemAtIndex( index ); if ( auto item = itemAtIndex( index ) )
removeAt( index );
if ( item == nullptr )
{ {
// how to get the spacer item and its settings ??? removeAt( index );
addSpacer( 30 ); addItem( item );
} }
else else
{ {
addItem( item ); const auto spacing = spacingAtIndex( index );
removeAt( index );
addSpacer( spacing );
} }
} }

View File

@ -82,6 +82,11 @@ int QskLinearBox::entryCount() const
return m_data->engine.count(); return m_data->engine.count();
} }
int QskLinearBox::spacingAtIndex( int index ) const
{
return m_data->engine.spacerAt( index );
}
QQuickItem* QskLinearBox::itemAtIndex( int index ) const QQuickItem* QskLinearBox::itemAtIndex( int index ) const
{ {
return m_data->engine.itemAt( index ); return m_data->engine.itemAt( index );

View File

@ -46,6 +46,8 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox
int itemCount() const { return entryCount(); } // items and spacers int itemCount() const { return entryCount(); } // items and spacers
#endif #endif
int spacingAtIndex( int index ) const;
QQuickItem* itemAtIndex( int index ) const; QQuickItem* itemAtIndex( int index ) const;
int indexOf( const QQuickItem* ) const; int indexOf( const QQuickItem* ) const;