SListView/STreeView Itemsource data type/conversion issue

Hi! I have a bit of a problem trying to assign my item source to a SListView/STreeView.

As per the example, it should be something like

SNew(SListView<TSharedPtr<UMyAssetType>>)
	.ItemHeight(24)
	.ListItemsSource(&MyStruct->MyArray)
	.OnGenerateRow(this, &FMyEditor::OnGenerateItemRow)

My data is setup like so.

UPROPERTY(EditDefaultsOnly, Instanced)
TArray<TObjectPtr<UMyAssetType>> MyArray;

this results in a

Cannot convert TArray<TObjectPtr<UMyAssetType>>* to TArray<TSharedPtr<UMyAssetType>>*

Has anyone encountered the same issue? What should be the best way to handle such data?
Cheers.

Try using the same type. You’re trying to assign array of TObjectPtr to an array of TSharedPtr.

If UMyAssetType is a UObject, you don’t need TSharedPtr, use TObjectPtr when creating the SListView. Then when you assign the array of TObjectPtr’s from your property, the types will match.

Hey, thanks!

I did that just after I posted the question and it worked. Thanks for the reply tho.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.