[Slate] SListView gives errors

Hi all, im currently trying to learn slate trying to build a custom ui for my plugin and im facing an odd error when i try to declare a SlistView in this way:

auto ListView = SNew(SListView<TSharedPtr<FString>>);

or even a full declaration

auto ListView = SNew(SListView<TSharedPtr<FString>>)
.OnGenerateRow(this, &FMypluginModule::OnGenerateRowForList)
	+ SHeaderRow::Column("Name")
+ SHeaderRow::Column("Number").DefaultLabel(TEXT("Number"))
+ SHeaderRow::Column("TextField").DefaultLabel(TEXT("Text Field"))
+ SHeaderRow::Column("TextBlock").DefaultLabel(TEXT("Text Block"))
+ SHeaderRow::Column("AddChild").DefaultLabel(TEXT("Add Child"))

This is the error list:

H:\Ue4Custom\4.13\UnrealEngine\Engine\Source\Runtime\Core\Public\Misc\Attribute.h(44): error C2664: 'FText::FText(const FText &)': cannot convert argument 1 from 'const FString' to 'FText::EInitToEmptyString'
2>  H:\Ue4Custom\4.13\UnrealEngine\Engine\Source\Runtime\Core\Public\Misc\Attribute.h(44): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
2>  H:\Users\Darky\Documents\Unreal Projects\Development-testing\Plugins\Myplugin\Source\Myplugin\Private\Myplugin.cpp(148): note: see reference to function template instantiation 'TAttribute<FText>::TAttribute<ObjectType>(const OtherType &)' being compiled
2>          with
2>          [
2>              ObjectType=FString,
2>              OtherType=FString
2>          ]
2>  H:\Users\Darky\Documents\Unreal Projects\Development-testing\Plugins\Myplugin\Source\Myplugin\Private\Myplugin.cpp(144): note: see reference to function template instantiation 'TAttribute<FText>::TAttribute<ObjectType>(const OtherType &)' being compiled
2>          with
2>          [
2>              ObjectType=FString,
2>              OtherType=FString
2>          ]
2>ERROR : UBT error : Failed to produce item: H:\Users\Darky\Documents\Unreal Projects\Development-testing\Plugins\Myplugin\Binaries\Win64\UE4Editor-Myplugin.pdb
2>  Total build time: 10,22 seconds
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(41,5): error MSB3075: The command "H:\Ue4Custom\4.13\UnrealEngine\Engine\Build\BatchFiles\Build.bat Development_TestingEditor Win64 Development "H:\Users\Darky\Documents\Unreal Projects\Development-testing\Development_Testing.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.

im currently wondering if i need some include files that are missing

FText doesn’t allow implicit construction from FString, which is what the error is (confusingly, since it chose an odd constructor) telling you.

It’s probably the DefaultLabel that’s complaining. You can use FText::FromString if this is just testing data, or LOCTEXT/NSLOCTEXT if you actually want your user-facing text to be localisable.

ive changed a little bit the things in this way

TArray<TSharedPtr<FText>> list;
list.Add(MakeShareable( new FText(FText::FromString("TEST"))));
list.Add(MakeShareable(new FText(FText::FromString("TEST@"))));
auto ListView = SNew(SListView<TSharedPtr<FText>>)
	.OnGenerateRow(this, &FMypluginModule::OnGenerateRowForList);

And without the last line it compile fine but with it still give weird errors

2>h:\ue4custom\4.13\unrealengine\engine\source\runtime\core\public\delegates\DelegateSignatureImpl.inl(181): error C2039: 'AsShared': is not a member of 'FMypluginModule'
2>  H:\Users\Darky\Documents\Unreal Projects\Development-testing\Plugins\Myplugin\Source\Myplugin\Public\Myplugin.h(10): note: see declaration of 'FMypluginModule'
2>  H:\Ue4Custom\4.13\UnrealEngine\Engine\Source\Runtime\Slate\Public\Widgets\Views\SListView.h(67): note: see reference to function template instantiation 'TBaseDelegate<TSharedRef<ITableRow,0>,ArgumentType,const TSharedRef<STableViewBase,0> &> TBaseDelegate<TSharedRef<ITableRow,0>,ArgumentType,const TSharedRef<STableViewBase,0> &>::CreateSP<UserClass,>(UserClass *,TSharedRef<ITableRow,0> (__cdecl FMypluginModule::* )(ArgumentType,const TSharedRef<STableViewBase,0> &))' being compiled
2>          with
2>          [
2>              ArgumentType=TSharedPtr<FText,0>,
2>              UserClass=FMypluginModule
2>          ]

and this is the FMypluginModule::OnGenerateRowForList functions maybe i declared this one wrong but it seems ok

TSharedRef<ITableRow> FMypluginModule::OnGenerateRowForList(TSharedPtr<FText> Item, const TSharedRef<STableViewBase>& OwnerTable)
	//Create the row
	return SNew(STableRow< TSharedPtr<FText> >, OwnerTable)

The attribute syntactic sugar in Slate assumes that everything has an AsShared function, as its designed for use inside widgets, and widgets all derive from TSharedFromThis.

You’re trying to define some UI directly in your module, which doesn’t meet either of those requirements. You’d be better creating a class derived from SCompoundWidget and creating your custom widget in there.

This wiki page shows a basic example of an SCompoundWidget based class: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums.

yup totally correct !! now its working thanks a lot