SDetailsView - how to use outside PropertyEditor

I need SDetailsView widget in my editor module. But when I try to use it,I get bayzlion of linking errors:

GAEffectSpecStructCustomization.cpp.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl SDetailsViewBase::~SDetailsViewBase(void)" (??1SDetailsViewBase@@UEAA@XZ) referenced in function "int `public: __cdecl SDetailsView::SDetailsView(void)'::`1'::dtor$0" (?dtor$0@?0???0SDetailsView@@QEAA@XZ@4HA)
11>GAEffectSpecStructCustomization.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl SDetailsViewBase::HideFilterArea(bool)" (?HideFilterArea@SDetailsViewBase@@UEAAX_N@Z)
11>GAEffectSpecStructCustomization.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class TArray<class FPropertyPath,class FDefaultAllocator> __cdecl SDetailsViewBase::GetPropertiesInOrderDisplayed(void)const " (?GetPropertiesInOrderDisplayed@SDetailsViewBase@@UEBA?AV?$TArray@VFPropertyPath@@VFDefaultAllocator@@@@XZ)
11>GAEffectSpecStr

and so on.

So far I tried to include:

#include "IDetailsView.h"
#include "PropertyEditorModule.h"
#include "Editor/PropertyEditor/Public/PropertyEditing.h"
#include "Editor/PropertyEditor/Private/IDetailsViewPrivate.h"
#include "Editor/PropertyEditor/Private/SDetailsViewBase.h"
#include "Editor/PropertyEditor/Private/SDetailsView.h"

To no affair. I don’t know what else I would need to get it working.

Update: This is not the best way to do it. See my other answer.

My previous, not recommended method:

SDetailsView doesn’t seem supposed to be used outside private engine code. It’s even defined in a Private folder.

If your goal is to create a details panel like the World Settings one, you can use SSingleObjectDetailsPanel. You just need to add #import "SSingleObjectDetailsPanel" to your code and add "KismetWidgets" to your module’s .build.cs file, in PrivateDependencyModuleNames.

Then, create a widget class extending from SSingleObjectDetailsPanel and implement the correct methods. I guess a good and straight-forward example in the engine is the details panel for the SpriteEditor in Paper2D. Take a look at the file Engine\Plugins\2D\Paper2D\Source\Paper2DEditor\Private\SpriteEditor.cpp:252

#Better, easier way!

Found another way, even simpler and used with much more frequency in the engine source, so it’s probably the newest/better way to do it (because we know Paper2D, where I got my previous answer from, hasn’t been updated in a while).

Using the IDetailsView interface, the process is pretty straight forward. And the way it’s instantiated, you’re actually using a SDetailsView, just indirectly.

  1. Create a FDetailsViewArgs variable to set the detail view’s settings.
  2. Use FPropertyEditorModule::CreateDetailView to create an IDetailsView instance.
  3. Pass your UObject instance that needs its properties displayed to the IDetailsView::SetObject method.
  4. Add the IDetailsView instance as some widget’s child.

I’m using it as a child in a custom widget, but in the engine code, on the World Settings tab creation, they just used the IDetailsView directly. Here’s a shortened snippet of that as an example:

// includes
#include "PropertyEditorModule.h"
#include "IDetailsView.h"
...

// setup the detail view settings
FDetailsViewArgs DetailsViewArgs( false, false, true, FDetailsViewArgs::HideNameArea, false, GUnrealEd );
DetailsViewArgs.bShowActorLabel = false;

// create the detail view widget
WorldSettingsView = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor").CreateDetailView( DetailsViewArgs );

// set the object to have its properties displayed
WorldSettingsView->SetObject(GetWorld()->GetWorldSettings());

// create the tab with the details view in it
return SNew( SDockTab )
	[
		WorldSettingsView.ToSharedRef()
	];

You also need to add "KismetWidgets" to your module’s .build.cs file, in PrivateDependencyModuleNames.

1 Like