more accurate capturing for lambdas

This commit is contained in:
Uwe Rathmann 2017-12-14 09:41:41 +01:00
parent d63fae938d
commit 2500f5c8c4
10 changed files with 27 additions and 27 deletions

View File

@ -370,7 +370,7 @@ public:
setAlignment( button, Qt::AlignCenter ); setAlignment( button, Qt::AlignCenter );
connect( button, &QskPushButton::pressed, connect( button, &QskPushButton::pressed,
this, [ = ]() { shift( button->offset() ); } ); this, [ this, button ]() { shift( button->offset() ); } );
} }
} }

View File

@ -91,11 +91,11 @@ FlowLayoutPage::FlowLayoutPage( QQuickItem* parent ):
Box* box = new Box(); Box* box = new Box();
ButtonBox* buttonBox = new ButtonBox(); ButtonBox* buttonBox = new ButtonBox();
buttonBox->addButton( "Flip", [ = ]() { box->transpose(); } ); buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
buttonBox->addButton( "Mirror", [ = ]() { box->mirror(); } ); buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
buttonBox->addButton( "Rotate", [ = ]() { box->rotate(); } ); buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );
buttonBox->addButton( "Dim+", [ = ]() { box->incrementDimension( +1 ); } ); buttonBox->addButton( "Dim+", [ box ]() { box->incrementDimension( +1 ); } );
buttonBox->addButton( "Dim-", [ = ]() { box->incrementDimension( -1 ); } ); buttonBox->addButton( "Dim-", [ box ]() { box->incrementDimension( -1 ); } );
addItem( buttonBox, Qt::AlignTop | Qt::AlignLeft ); addItem( buttonBox, Qt::AlignTop | Qt::AlignLeft );
addItem( box ); addItem( box );

View File

@ -90,11 +90,11 @@ LinearLayoutPage::LinearLayoutPage( QQuickItem* parent ):
Box* box = new Box(); Box* box = new Box();
ButtonBox* buttonBox = new ButtonBox(); ButtonBox* buttonBox = new ButtonBox();
buttonBox->addButton( "Flip", [ = ]() { box->transpose(); } ); buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
buttonBox->addButton( "Mirror", [ = ]() { box->mirror(); } ); buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
buttonBox->addButton( "Rotate", [ = ]() { box->rotate(); } ); buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );
buttonBox->addButton( "Spacing+", [ = ]() { box->incrementSpacing( +1 ); }, true ); buttonBox->addButton( "Spacing+", [ box ]() { box->incrementSpacing( +1 ); }, true );
buttonBox->addButton( "Spacing-", [ = ]() { box->incrementSpacing( -1 ); }, true ); buttonBox->addButton( "Spacing-", [ box ]() { box->incrementSpacing( -1 ); }, true );
addItem( buttonBox, Qt::AlignTop | Qt::AlignLeft ); addItem( buttonBox, Qt::AlignTop | Qt::AlignLeft );
addItem( box ); addItem( box );

View File

@ -107,11 +107,11 @@ StackLayoutPage::StackLayoutPage( QQuickItem* parent ):
auto* box = new Box(); auto* box = new Box();
auto* buttonBox = new ButtonBox(); auto* buttonBox = new ButtonBox();
buttonBox->addButton( "<<", [ = ]() { box->incrementScrolling( Qt::Horizontal, +1 ); } ); buttonBox->addButton( "<<", [ box ]() { box->incrementScrolling( Qt::Horizontal, +1 ); } );
buttonBox->addButton( ">>", [ = ]() { box->incrementScrolling( Qt::Horizontal, -1 ); } ); buttonBox->addButton( ">>", [ box ]() { box->incrementScrolling( Qt::Horizontal, -1 ); } );
buttonBox->addButton( "^", [ = ]() { box->incrementScrolling( Qt::Vertical, -1 ); } ); buttonBox->addButton( "^", [ box ]() { box->incrementScrolling( Qt::Vertical, -1 ); } );
buttonBox->addButton( "v", [ = ]() { box->incrementScrolling( Qt::Vertical, +1 ); } ); buttonBox->addButton( "v", [ box ]() { box->incrementScrolling( Qt::Vertical, +1 ); } );
buttonBox->addButton( "Fading", [ = ]() { box->incrementFading( +1 ); } ); buttonBox->addButton( "Fading", [ box ]() { box->incrementFading( +1 ); } );
auto pageIndicator = new QskPageIndicator(); auto pageIndicator = new QskPageIndicator();
pageIndicator->setCount( box->itemCount() ); pageIndicator->setCount( box->itemCount() );

View File

@ -143,7 +143,7 @@ public:
0.5 * ( slider->maximum() - slider->minimum() ) ); 0.5 * ( slider->maximum() - slider->minimum() ) );
#if 0 #if 0
connect( slider, &QskSlider::valueChanged, connect( slider, &QskSlider::valueChanged,
[ = ]( qreal value ) { qDebug() << value; } ); []( qreal value ) { qDebug() << value; } );
#endif #endif
setAlignment( slider, Qt::AlignCenter ); setAlignment( slider, Qt::AlignCenter );
} }

View File

@ -98,10 +98,10 @@ public:
// 2) QskInputPanel does not work properly in the threaded environment // 2) QskInputPanel does not work properly in the threaded environment
#if 1 #if 1
connect( this, &QskListView::selectedRowChanged, connect( this, &QskListView::selectedRowChanged,
this, [ = ] { qskSetup->inputPanel()->setLocale( m_values[selectedRow()].second ); } ); this, [ this ] { qskSetup->inputPanel()->setLocale( m_values[selectedRow()].second ); } );
#else #else
connect( this, &QskListView::selectedRowChanged, connect( this, &QskListView::selectedRowChanged,
this, [ = ] { QLocale::setDefault( m_values[selectedRow()].second ); } ); this, [ this ] { QLocale::setDefault( m_values[selectedRow()].second ); } );
#endif #endif
} }

View File

@ -140,13 +140,13 @@ void QskAnimatorDriver::registerAnimator( QskAnimator* animator )
m_windows += window; m_windows += window;
connect( window, &QQuickWindow::afterAnimating, connect( window, &QQuickWindow::afterAnimating,
this, [ = ]() { advanceAnimators( window ); } ); this, [ this, window ]() { advanceAnimators( window ); } );
connect( window, &QQuickWindow::frameSwapped, connect( window, &QQuickWindow::frameSwapped,
this, [ = ]() { scheduleUpdate( window ); } ); this, [ this, window ]() { scheduleUpdate( window ); } );
connect( window, &QObject::destroyed, connect( window, &QObject::destroyed,
this, [ = ]( QObject* ) { removeWindow( window ); } ); this, [ this, window ]( QObject* ) { removeWindow( window ); } );
window->update(); window->update();
} }

View File

@ -61,7 +61,7 @@ void QskDirtyItemFilter::addWindow( QQuickWindow* window )
*/ */
connect( window, &QQuickWindow::beforeSynchronizing, connect( window, &QQuickWindow::beforeSynchronizing,
window, [ = ] { beforeSynchronizing( window ); }, window, [ this, window ] { beforeSynchronizing( window ); },
Qt::DirectConnection ); Qt::DirectConnection );
connect( window, &QObject::destroyed, this, &QskDirtyItemFilter::cleanUp ); connect( window, &QObject::destroyed, this, &QskDirtyItemFilter::cleanUp );

View File

@ -125,9 +125,9 @@ void QskSubWindowArea::itemChange( QQuickItem::ItemChange change,
case QQuickItem::ItemChildAddedChange: case QQuickItem::ItemChildAddedChange:
{ {
// the child is not fully constructed // the child is not fully constructed
// and we have delay checking for sub windows // and we have to delay checking for sub windows
QTimer::singleShot( 0, this, QTimer::singleShot( 0, this,
[ = ] { qskUpdateEventFilter( this ); } ); [ this ] { qskUpdateEventFilter( this ); } );
break; break;
} }

View File

@ -133,11 +133,11 @@ int QskTabBar::insertTab( int index, QskTabButton* button )
button->setTextOptions( m_data->textOptions ); button->setTextOptions( m_data->textOptions );
auto onTabSelected = auto onTabSelected =
[ = ] ( bool on ) [ this, button ] ( bool on )
{ {
if ( on ) if ( on )
{ {
int pos = indexOf( button ); const int pos = indexOf( button );
if ( pos >= 0 && pos != m_data->currentIndex ) if ( pos >= 0 && pos != m_data->currentIndex )
{ {
m_data->currentIndex = pos; m_data->currentIndex = pos;