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"

Sharing a SverticalBox between BP and c++ ?

Hi,

How do i share a SVerticalBox between blueprint and c++ ?

I'd like to fill a SVerticalBox in c++.

I see two possible strategies:

  • create the SVerticalBox in c++ and expose it to the BP

  • create the SVerticalBox in the BP and pass it to an exposed c++ function

I could succeed in none of those.

The following code is in the UUserWidget that the BP inherits from.

The problem is that those 4 tries give me an "unrecognized type" at compilation (TSharedPrt or SVerticalBox).

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = yag)
     SVerticalBox* ResolutionBox;
 
 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = yag)
     TSharedPtr<SVerticalBox> ResolutionBox;
 
 UFUNCTION(BlueprintCallable, Category = "Yag")
     void SetupResolutions(SVerticalBox* ResolutionBox);
 
 UFUNCTION(BlueprintCallable, Category = "Yag")
     void SetupResolutions(TSharedPtr<SVerticalBox> ResolutionBox);


This one:

 UFUNCTION(BlueprintCallable, Category = "Yag")
     void SetupResolutions(UUserWidget* UResolutionBox);

is compiling but within my function i don't know how to go from a UUserWidget to a SVerticalBox.

I tried different combinations of Casting, TSharedRef, TSharedPtr, couldn't find one that works.

Thanks for any pointers (pun almost intended^^) in the right direction !

Cedric

Product Version: UE 4.14
Tags:
more ▼

asked Dec 28 '16 at 07:29 PM in C++ Programming

avatar image

uced
860 75 93 362

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

1 answer: sort voted first

Still no answer but a cool workaround in case anyone is stuck too.

I use the FindWidget function:

 UVerticalBox* UVerticalBox_Resolutions = (UVerticalBox*)(WidgetTree->FindWidget(FName(TEXT("VerticalBox_Resolutions"))));

In my UMG widget i create a verticalbox named "VerticalBox_Resolutions", and in the code i add the hereabove line.

I'll mark this as solved as it works well, but if anyone has a better solution that would answer directly my initial question, please do share it :-)

Cheers

Cedric

more ▼

answered Jan 01 '17 at 02:19 PM

avatar image

uced
860 75 93 362

(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