How do I display UTexture2D on UImage?

Since no one has answered, I’ll take a shot though I’ve not directly referenced a UMG in this manner from C++. I use BP UMGs parented to a C++ parent that makes variables accessible to the BP child and let the BP do the settings via events. Just saying, my advice is probably not valuable.

SetVisibility stands without a pointer to m_pMainImage so you are attempting to set visibility on the entire UMG Class (which I’m not versed in why such a thing would be done). If that is your intent, then my comment is useless. But if you are attempting to set the visibility of the image, it would seem you should have a pointer to that image widget on that statement. Possibly something like

m_pMainImage->SetVisibility(ESlateVisibility::Visible);