Slate, Hello Tutorial Problem Widget Crash Reporter

Hi, I’m following the tutorial

[link text][1]


// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;

public class HelloSlate : ModuleRules
	public HelloSlate(ReadOnlyTargetRules Target) : base(Target)
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

		PrivateDependencyModuleNames.AddRange(new string[] {  });

		// Uncomment if you are using Slate UI
		PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
		// Uncomment if you are using online features
		// PrivateDependencyModuleNames.Add("OnlineSubsystem");

		// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true


Slate Widget:

I think that’s where the problem is

Error .h:

a type reference “SStandardSlateWidget::FArguments::WidgetArgsType &” (not qualified constant) can not be initialized with a type value “SStandardSlateWidget::FArguments” HelloSlate 13

I do not know how to solve it when compiling:

The crash happens on hot reload, you might as well ignore it if nothing happens normally. It would be good if you do debugging because crash most likely happens on destructor inside generated code and we don’t know what inside there causing the crash. Also try looking on logs in Saved/Logs in you project you might find more info whats happening there

My guess is the main cause is fact you using slate varbales inside UObject, i did this in the past but without hotreload as you mostly does that in plugins which don’t hot reload at all. There defiantly way to solve this as UMG use slate without such issues, but you need to provide more info, or study UWidget class.

Only thing i notice about tutorial code using SNew insted of SAssignNew to set pointer, normally you should do this, also by convention and better readability you should new line before argument and tabbulate:


Now the impotent part that i think i need to tell you (and really why i post this as answer). I don’t know if you or author of this tutorial is aware of that, but UMG is Slate blueprint front end. Main reason why UMG was made in first palce is to allow to interact with Slate in blueprint, because Slate object as you may already notice by need ot use TSharedPtr and TWeakObjectPtr and lack of typical macros in slate is not inherent from UObject and it can not be used in blueprint without UObject wrapper class which your AStandardHUD became and UMG is using UWidget class for same reason.

So what you doing could be done a lot easier with UMG by making your own UWidget, this way you make Slate widget work with UMG + it should fix the hot reload problem as i didnt have issue with it

All you need to do in UWidget is override ConstructWidget(), return value with SNew or SAssignNew with widget you want to make:

In fact you don’t need to create Slate widget class as Slate allows you to construct widget on the go (nested widget) with SNew (same as you did in ChildSlot) which is one of the beauty of using Slate in C++ over UMG

Other impotent part you need to override SynchronizeProperties which will be caleld when widget is edited in UMG editor, you need to sync UWidget with your slate widget otherwise you wont see changes of widget when you edit it.

For runtime you need to make Set functions to update the widget or do this on Tick. You may also need to call this function:

For examples, go to engine source code and see how UMG widgets are made, most of them are very simple as all they do is wrap single Slate widgets to be usable in UMG:

But nothing stops you from controlling entire composition of slate widget this way. Just keep in mind that single SWidget won’t be editable in UMG rether entire UWidget is most minimal component you can control in UMG editor.

Now one more thing, if you doing this to control widget in C++, there way to do this avoiding use of Slate. All you need to do is to create your own UUserWidget which is class which widget blueprint generating, then make blueprint (not widget blueprint) based of that UUserWidget and it will open widget editor insted of blueprint editor (you need to watch out because widget editor does not support reparenting, so once oyu do this you can not change the parent of widget blueprint), with you C++ class as a base. What this means? You can make BlueprintImplementableEvent or BlueprintNativeEvent to send call in to the widget, so if you want to show message on widget you make event ShowMessage, which then widget blueprint will set text and fire up fency animation for example. This is what i personally usually do as UMG is a lot easier to manipulate with widgets then Slate C++ declaration, i only use Slate when i hit limitations of UMG (not all Slate widgets are wrapped to UMG for example) or need to do editor extension which you can use only Slate with it.

thanks is the best explanation! I will put into practice all the points mentioned.