Hello,
I am trying to use the new Lambda method for a static QTimer call.
C++11 is enabled in the .pro file and I am working with Qt 5.5.1.
I am getting a segfault on line 6 when I try to use the following code snipped.
From my understanding this should generally use references to local variables except for the item pointer.
Since I manipulate the item, the lambda function has to use the mutable keyword.
{
QBrush brush
= item
->background
();
item->setBackground(Qt::blue);
QTimer::singleShot(1000,
[&, item
]() mutable
{ item->setBackground(brush);
});
}
void myWidget::modelItemChanged(QStandardItem *item)
{
QBrush brush = item->background();
item->setBackground(Qt::blue);
QTimer::singleShot(1000, [&, item]() mutable {
item->setBackground(brush);
});
}
To copy to clipboard, switch view to plain text mode
Would appreciate your help.
Bookmarks