Unable to use UGridPanel Widget in C++ Script

Hello,

I want to try and use the UGridPanel* widget in my C++ UUserWidget component but I only get the expression must have class type but it has "UGridPanel *". Not sure what is going wrong, I am referencing it in the same way as my UProgressBar* and I get set the percentage on that widget without issues.

I have a GPRecipeCards Grid Panel widget in the widget blueprint and Is Variable is set to true.

// UW_HUD.h snippet
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include <Recipe.h>
#include "UW_RecipeCard.h"
#include "UW_HUD.generated.h"

UCLASS()
class MYECOGAME_API UUW_HUD : public UUserWidget
{
	GENERATED_BODY()

public:
	// Update HUD with new health
	void SetHealth(float Health, float MaxHealth);

	// Update the recipes
	void SetRecipesCards(TArray<Recipe*> Recipes);

	// Widget to display health
	UPROPERTY(EditAnywhere, meta = (BindWidget))
	class UProgressBar* PBHealth;

	// Widget to display recipes cards
	UPROPERTY(EditAnywhere, meta = (BindWidget))
	class UGridPanel* GPRecipeCards;
};
// UW_HUD.cpp snippet
#include "UW_HUD.h"
#include "Components/ProgressBar.h"
#include <Components/TileView.h>
#include "Components/GridPanel.h"
#include <Recipe.h>

void UUW_HUD::SetHealth(float Health, float MaxHealth) {
	if (PBHealth) {
		PBHealth->SetPercent(Health / MaxHealth);
	}
}

void UUW_HUD::SetRecipesCards(TArray<Recipe*> Recipes) {
	UE_LOG(LogTemp, Error, TEXT("HUD trying to set %d recipes"), Recipes.Num());

	if (RecipeCardClass) {
		UUW_RecipeCard* NewRecipeCard = CreateWidget<UUW_RecipeCard>(GetWorld(), RecipeCardClass, FName("Recipe Card"));
		NewRecipeCard->SetTime(1, 5);
		
		if (GPRecipeCards) {
			GPRecipeCards.AddChildToGrid(); // Error occurs here when I try to reference GPRecipeCards
			// GPRecipeCards.AddChildToGrid(...);
		}
	}
}

Thank you

GPRecipeCards is pointer so to call AddChildToGrid function you have to dereference the pointer first with (->) instead of (.) so try GPRecipeCards->AddChildToGrid();

You should be a little more clear about where the error happens.
Which line does the error point to?

My guess is that you may need to include the header file for GridPahel in your header.

// put this before UW_HUD.generated.h
#include "Components/GridPanel.h"

Oh, I see – the second code snippet had a comment about the error.
Yeah, in this case, I agree with @BULLSEYEliTe – you need to use -> to dereference pointers!