list view has background fill and I dont know how disable it.
Hi, xhn. Seems Epic changed the default style of all Widget elements into dark theme. I spend some time to figure out a solution for C++ project.
Here is the sample class that provide transparent background:
#pragma once
#include "CoreMinimal.h"
#include "Components/ListView.h"
#include "TransparentListView.generated.h"
/**
* A List View class with transparent background.
*/
UCLASS()
class UTransparentListView : public UListView
{
GENERATED_BODY()
protected:
virtual TSharedRef<STableViewBase> RebuildListWidget() override;
protected:
FTableViewStyle TransparentTableViewStyle;
};
TransparentListView.h
#include "UI/Widget/TransparentListView.h"
TSharedRef<STableViewBase> UTransparentListView::RebuildListWidget()
{
TSharedRef<SListView<UObject*>> NewWidget = ConstructListView<SListView>();
FSlateBrush TransparentBrush;
TransparentBrush.TintColor = FSlateColor(FLinearColor{1.f, 1.f, 1.f, 0.f});
TransparentTableViewStyle = FAppStyle::Get().GetWidgetStyle<FTableViewStyle>("ListView");
TransparentTableViewStyle.SetBackgroundBrush(TransparentBrush);
NewWidget->SetStyle(&TransparentTableViewStyle);
return NewWidget;
}
TransparentListView.cpp
If you want to adjust the background color, you can add a FLinearColor variable with
UPROPERTY(EditDefaultOnly, BlueprintReadOnly)
specifiers. And pass this value into TransparentBrush.TintColor property. It should works as expect.
Worked for me, thanks!
I’ll add that you need to add "Slate"
and "SlateCore"
to the DependencyModuleNames.
hi I want to do this too
but I don’t know how to implement c++ in blueprint project
could you shared your method or link to some tutorial about it
thank you
Implement new C++ class from Unreal 5:
Menu: Tolls/New C++ Class…
Switch to: All Classes
Search for: ListView (Object/Visual/Widget/ListViewBase/ListView)
Next, give name and location
Find generated files and edit as List view background problem - #2 by Last_Soldier
Build solution (Visual Studio)
Errors will be generated.
Need to add Slate and SlateCore to dependeces.
Find PathToMyUnrealProject\Source\MyUnrealProject\MyUnrealProject.Build.cs and edit so public dependeces look like
PublicDependencyModuleNames.AddRange(new string[] { “Core”, “CoreUObject”, “Engine”, “InputCore”, “Slate”, “SlateCore” });
Basicaly adding
, “Slate”, “SlateCore”
to existing list.
If in PathToMyUnrealProject\Source\MyUnrealProject\MyUnrealProject.Build.cs
You find lines like these uncomment like this:
// Uncomment if you are using Slate UI
PrivateDependencyModuleNames.AddRange(new string[] { “Slate”, “SlateCore” });
This is like a foreign language to me and I have no idea what to do with it
You can also try TileView instead of ListView. TileView doesn’t have this background.