can you make reference from blueprint variable to c++ code?

Hello
I’m quite noobie to Unreal c++ and are wondering, if i make a component for inventory and that is in c++ code and want to reference a UI by putting it in a variable in blueprint, is it possible for me to somehow reference UI variable from blueprint to a c++ code class or do i need to also make the UI a c++ code?

If you have a C++ component that has a property marked with UPROPERTY(BlueprintReadOnly) (or BlueprintReadWrite) you should be able to access that property from your Widget blueprint without problems. No need to use C++ for that. Your component might be declared as UCLASS(BlueprintType) in order to be assigned to a variable.

how can i get access from it, do i just type the name in? like

variable in blueprint name: UI_W

UPROPERTY(BlueprintReadWrite)
UUserWidget* UI_W

is it something like this?

That would be having a reference of a widget inside of your C++ class. Isn’t that the opposite of what you are trying to achieve?

From my understanding you would want to have a widget blueprint that has a reference to your inventory component. So in the blueprint editor you would create a variable of type “inventory component” and make it public editable, may be even"expose on spawn".

Now after creating you can pass your inventory component over to your widget and use that to display its data.

actually yes, you are correct, i get confused with these codes alot xd

so if i get it straight, i should:

  1. create variable in bluepirnt
  2. name it inventory component
  3. make it public
    4.then assign either inventory component or the UI Widget