Функция:
Код: Выделить всё
auto takeTopLevelItem = []( QTreeWidget* aTreeWidget, const QString& aText )
{
const int count = aTreeWidget->topLevelItemCount();
for ( int index = 0; index < count; ++index )
{
auto item = aTreeWidget->topLevelItem( index );
if ( item->text( 0 ) == aText )
{
return aTreeWidget->takeTopLevelItem( index );
}
}
return nullptr; // This causes a compilation error.
};
Ошибка 1, ошибка C3487: 'nullptr': all возвращаемые выражения в лямбда-выражении должны иметь один и тот же тип: ранее это было 'QTreeWidgetItem *' cpp 251
Я изменил указанную строку на эту и теперь он компилируется:
Код: Выделить всё
return (QTreeWidgetItem*)( nullptr );
Я использую Visual Studio 2012.
Подробнее здесь: https://stackoverflow.com/questions/307 ... a-function
Мобильная версия