createdefaultsubobject 函数不适用于 UWidgetComponent[UE4.26.2]

The createdefaultsubobject function does not work for UWidgetComponent[UE4.26.2]

在构造函数中创建类型为 UWidgetComponent 的对象时,会抛出编译错误。如何解决这个问题?
更改了 属性 宏的不同变体也没有帮助也尝试使用新对象函数创建对象也没有帮助

//.h

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TestWidgetActor.generated.h"

UCLASS()
class TESTPROJECT_API ATestWidgetActor : public AActor
{
    GENERATED_BODY()
    
public: 
    // Sets default values for this actor's properties
    ATestWidgetActor();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

    UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Test")
        class UWidgetComponent* TestWidgetComponent;
    
public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

};

//.cpp

#include "TestWidgetActor.h"
#include "Components/Widget.h"
#include "Components/WidgetComponent.h"

// Sets default values
ATestWidgetActor::ATestWidgetActor()
{
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;
    this->TestWidgetComponent = CreateDefaultSubobject<UWidgetComponent>("Widget component");
    this->TestWidgetComponent->SetupAttachment(GetRootComponent());
}

//错误

Error LNK2019 reference to an unresolved external character "__declspec(dllimport) private: static class Class * __cdecl UWidgetComponent:: GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UWidgetComponent@@CAPEAVUClass@@XZ) in the function "public: __cdecl ATestWidgetActor::ATestWidgetActor(void)" (?? 0ATestWidgetActor@@QEAA@XZ). Test Project C:\Users\mark\Documents\Unreal Project\Test Project\Intermediate\Project Files\Test Widget Actor.cpp.obj 1

该函数在不同的模块中,您没有在构建脚本(*.build.cs 文件)中添加该模块的依赖项

pic.jpg