So I have this simple widget:
ChildSlot
.VAlign(VAlign_Fill)
.HAlign(HAlign_Fill)
[
SNew(SOverlay)
+SOverlay::Slot()
.HAlign(EHorizontalAlignment::HAlign_Center)
.VAlign(EVerticalAlignment::VAlign_Top)
[
SNew(STileView)
.ListItemsSource(&PowersList)
.OnGenerateTile(&SRPGPowerInventoryWidget::SOnGenerateWidgetForList)
]
];
TSharedRef SRPGPowerInventoryWidget::SOnGenerateWidgetForList( URPGPowerBase* InItem )
{
return SNew(STextBlock).Text( FString(InItem->Description) );
}
I have based it on this comment found in SListView.h
* A trivial use case appear below:
*
* Given: TArray< FString* > Items;
*
* SNew( SListView< FString* > )
* .ItemHeight(24)
* .ListItemsSource( &Items )
* .OnGenerateRow( SListView< TSharedPtr >::MakeOnGenerateWidget( this, &MyClass::OnGenerateRowForList ) )
*
* In the example we make all our widgets be 24 screen units tall. The ListView will create widgets based on data items
* in the Items TArray. When the ListView needs to generate an item, it will do so using the OnGenerateWidgetForList method.
*
* A sample implementation of OnGenerateWidgetForList would simply return a TextBlock with the corresponding text:
*
* TSharedRef OnGenerateWidgetForList( FString* InItem )
* {
* return SNew(STextBlock).Text( (*InItem) )
* }
*
*/
Since there is no function MakeOnGenerateWidget, I have skipped this part.
And during compilation I get this error:
1>D:\Unreal\RPG\Source\RPG\HUD\Widgets\SRPGPowerInventoryWidget.cpp(37): error C2664: 'STileView::FArguments &STileView::FArguments::OnGenerateTile(const TBaseDelegate_RetVal_TwoParams &)' : cannot convert parameter 1 from 'TSharedRef (__cdecl SRPGPowerInventoryWidget::* )(URPGPowerBase *)' to 'const TBaseDelegate_RetVal_TwoParams &'
1> with
1> [
1> ItemType=URPGPowerBase *,
1> RetValType=TSharedRef,
1> Param1Type=URPGPowerBase *,
1> Param2Type=const TSharedRef &
1> ]
1> and
1> [
1> ObjectType=ITableRow
1> ]
1> and
1> [
1> RetValType=TSharedRef,
1> Param1Type=URPGPowerBase *,
1> Param2Type=const TSharedRef &
1> ]
1> Reason: cannot convert from 'TSharedRef (__cdecl SRPGPowerInventoryWidget::* )(URPGPowerBase *)' to 'const TBaseDelegate_RetVal_TwoParams'
1> with
1> [
1> ObjectType=ITableRow
1> ]
1> and
1> [
1> RetValType=TSharedRef,
1> Param1Type=URPGPowerBase *,
1> Param2Type=const TSharedRef &
1> ]