I have the following array, which I want to render as a slate list:
TArray<FArtifact> Artifacts;
As far as I know, SListView can only be used with an array of pointers to UObject, shared refs and shared pointers. So, as in my case it is structs, I will have to somehow convert my array to an array of either TSharedPtr< FArtifact > or TSharedRef< FArtifact >. I’ve tried something like that:
// Array to keep shared pointers to my structs
TArray<TSharedPtr<FArtifact>> ArtifactsPtrs;
// Creating shared pointers to the original objects
for (auto Artifact : Artifacts)
ArtifactsPtrs.Add(MakeShareable(&Artifact));
// Trying to construct SListView
SNew(SListView<TSharedPtr<FArtifact>>)
.ListItemsSource(&ArtifactsPtrs)
.OnGenerateRow_Lambda([](TSharedPtr<FArtifact> Artifact, const TSharedRef<STableViewBase>& OwnerTable)->TSharedRef<ITableRow>{ return SNew(STableRow<TSharedPtr<FArtifact>>, OwnerTable)[SNew(STextBlock).Text(Artifact->Name)]; })
It compiles OK, but on run, I have editor crash with the following log (in the attachment).
I’ve spend the whole day trying to make it work, but no luck so far ![]()
Would very appreciate any hints, thank you!