Hello everyone
I was trying to create a Combo Box with slate, but I got some errors when I add the function “,OnGenerateWidget”.
This is my function code
TSharedRef<ITableRow> SOptionsWidget::GenerateWidget(TSharedPtr<FIntPoint> Item, const TSharedRef<STableViewBase>& OwnerTable)
{
if (!Item.IsValid())
{
return SNew(SComboRow<TSharedPtr<FIntPoint>>, OwnerTable).Content()
[
SNew(STextBlock)
.Text(FText::FromString("Error"))
];
}
return SNew(SComboRow<TSharedPtr<FIntPoint>>, OwnerTable).Content()
[
SNew(STextBlock)
.Text(FText::Format(FText::FromString("{0}x{1}"), FText::FromString(FString::FromInt(Item->X)), FText::FromString(FString::FromInt(Item->Y))))
.ColorAndOpacity(FColor::Black)
];
}
And I got this error
Error 1 error C2664: 'SComboBox<TSharedPtr<FIntPoint,0>>::FArguments &SComboBox<TSharedPtr<FIntPoint,0>>::FArguments::OnGenerateWidget(const TBaseDelegate<TSharedRef<SWidget,0>,ArgumentType> &)' : cannot convert argument 2 from 'TSharedRef<ITableRow,0> (__cdecl SOptionsWidget::* )(TSharedPtr<FIntPoint,0>,const TSharedRef<STableViewBase,0> &)' to 'TSharedRef<SWidget,0> (__cdecl SOptionsWidget::* )(ArgumentType)' C:\Users\Samuel\Documents\Unreal Projects\Project2DCpp\Source\Project2DCpp\Private\SOptionsWidget.cpp 60 1 Project2DCpp
4 IntelliSense: no instance of overloaded function "SComboBox<OptionType>::FArguments::OnGenerateWidget [with OptionType=TSharedPtr<FIntPoint, ESPMode::NotThreadSafe>]" matches the argument list
argument types are: (SOptionsWidget *, TSharedRef<ITableRow, ESPMode::NotThreadSafe> (SOptionsWidget::*)(TSharedPtr<FIntPoint, ESPMode::NotThreadSafe> Item, const TSharedRef<STableViewBase, ESPMode::NotThreadSafe> &OwnerTable))
object type is: SComboBox<TSharedPtr<FIntPoint, ESPMode::NotThreadSafe>>::FArguments c:\Users\Samuel\Documents\Unreal Projects\Project2DCpp\Source\Project2DCpp\Private\SOptionsWidget.cpp 60 7 Project2DCpp
The line 60 is: “.OnGenerateWidget(this, &SOptionsWidget::GenerateWidget)”
How can I get this working properly?
Sorry for my English
Thanks!