按上图需要的继承类来写自己的slate控件
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"
/**
*
*/
DECLARE_DELEGATE_OneParam(FOnButtonDown,FString)
class SLATETEST_API SSCustomWidget : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SSCustomWidget)
{
_Message = TEXT("Hello");//这样设置参数的默认值
}
// 将要传递的参数放到反射系统,这样就可以在SNew之后为该变量赋值
SLATE_EVENT(FOnButtonDown,OnButtonDown);
SLATE_ARGUMENT(FString,Message);
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments