x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Slate, Hello Tutorial Problem Widget Crash Reporter

Hi, I'm following the tutorial

link text

HelloSlate.Build.cs

 // 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
     }
 }


HUD:

alt text

alt text


Slate Widget:

I think that's where the problem is

alt text

Error .h:

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

alt text


I do not know how to solve it when compiling:

alt text

Product Version: UE 4.22
Tags:
crash-reporter.png (66.6 kB)
standardhudh.png (21.6 kB)
standardhudcpp.png (34.4 kB)
slateh.png (28.2 kB)
slatecpp.png (46.6 kB)
more ▼

asked May 20 '19 at 08:19 PM in C++ Programming

avatar image

danielf94
61 2 5 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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:

 SAssignNew(MyUIWidget,SStandardSlateWidget)
        .OwnerHUDArg(this);

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:

https://api.unrealengine.com/INT/API/Runtime/UMG/Components/UWidget/RebuildWidget/index.html

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.

https://api.unrealengine.com/INT/API/Runtime/UMG/Components/UWidget/SynchronizeProperties/index.html

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:

https://api.unrealengine.com/INT/API/Runtime/UMG/Components/UWidget/InvalidateLayoutAndVolatility/index.html

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:

https://github.com/EpicGames/UnrealEngine/tree/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Source/Runtime/UMG/Public/Components https://github.com/EpicGames/UnrealEngine/tree/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Source/Runtime/UMG/Private/Components

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.

more ▼

answered May 21 '19 at 02:52 AM

avatar image

Shadowriver
36.6k 931 169 1111

avatar image danielf94 May 21 '19 at 02:41 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question