How to change OutlineSettings CornerRadii in C++

Hello,

I created a first widget Blueprint.

I have added a UButton in my widget with Image and TextBlock call ToolButton

Then I created a second widget ToolBar with multiple ToolButtons.

After set my blueprint I just create cpp and header file in my project for the logic (I don’t want to use the Graph section of Blueprint because I do not understand it). Then I created widgets binding in header file for each buttons of my ToolBar, I use UMG.

In the Blueprint Designer section of Unreal Engine I have custom the Style of my ToolButton.

So I change Draw As for Rounded Box which is a ESlateBrushDrawType enumeration.

I change too the Outline Settings Corner Radii, by default I set all corners radius to 0.0

And I set Rounding Type to Fixed Radius.

The problem is : I want to change the Corner Radii of Outline Settings of the first button in my ToolBar and the last button because I want they are rounded to make my bar rounded. If I change it in my ToolButton it will affect all other buttons in my ToolBar.

I have seen I can modify in C++ the Draw As settings like this :

ToolButton->WidgetStyle.Normal.DrawAs = ESlateBrushDrawType::Image; // If I want to draw it as an image but I don’t want of course it is just an example.

I search for how to do the same thing for Outline Settings and Corner Radii but I cannot find anything about it so please help me if you know how to do that.

I don’t know if its relevant or not, but if someone needs it in the future:

TObjectPtr<UButton> ButtonWidget;
FButtonStyle& NewButtonStyle = ButtonWidget->WidgetStyle;
NewButtonStyle.Normal.DrawAs = ESlateBrushDrawType::RoundedBox;
NewButtonStyle.Normal.OutlineSettings.CornerRadii = FVector4(0,0,0,0);

ButtonWidget->SetStyle(NewButtonStyle);

When directly accesing the ButtonWidget->WidgetStyle property I get a warning telling me that direct access to WidgetStyle is deprecated, and so I should use get() set().
But there was just no way I could get this work without the direct access.

This topic has been moved from International to Programming & Scripting.

When posting, please review the categories to ensure your topic is posted in the most relevant space.

Thanks RonaldoAlmeida,

I did like that :

UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
class UButton* ToolButton;

void UToolBarButton::SetCornerRadius(bool isRight, float radius) {
FButtonStyle Style = ToolButton->GetStyle();

if (isRight) {
    Style.Normal.OutlineSettings.CornerRadii.Y = radius; /** Y : Right top corner */
    Style.Normal.OutlineSettings.CornerRadii.Z = radius; /** Z : Right bottom corner */
    Style.Hovered.OutlineSettings.CornerRadii.Y = radius;
    Style.Hovered.OutlineSettings.CornerRadii.Z = radius;
    Style.Pressed.OutlineSettings.CornerRadii.Y = radius;
    Style.Pressed.OutlineSettings.CornerRadii.Z = radius;
    Style.Disabled.OutlineSettings.CornerRadii.Y = radius;
    Style.Disabled.OutlineSettings.CornerRadii.Z = radius;
} else {
    Style.Normal.OutlineSettings.CornerRadii.X = radius;  /** X : Left top corner */
    Style.Normal.OutlineSettings.CornerRadii.W = radius; /** W: Left bottom corner */
    Style.Hovered.OutlineSettings.CornerRadii.X = radius;
    Style.Hovered.OutlineSettings.CornerRadii.W = radius;
    Style.Pressed.OutlineSettings.CornerRadii.X = radius;
    Style.Pressed.OutlineSettings.CornerRadii.W = radius;
}

ToolButton->SetStyle(Style);

}

I call it like this in my main widget (ToolBar) :
LeftButton->SetCornerRadius(false, 5.0f);
RightButton->SetCornerRadius(true, 5.0f);

I don’t know how you format your text and have your code same with your IDE style in this forum reply, I try to use Blockquote and Preformatted text but it does not work as your post.