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"

UFUNCTION causing build errors

I'm trying to create a function that can be overridden in blueprints, however any time I try to add the UFUNCTION prefix I get build errors.

ToolTipDesign.h

 #pragma once
 
 #include "Blueprint/UserWidget.h"
 #include "ToolTipDesign.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class MYPROJECT_API UToolTipDesign : public UUserWidget
 {
     GENERATED_BODY()
     
 public:
 
     UPROPERTY(BlueprintReadWrite, EditAnywhere)
     FText MyToolTipText;
 
     virtual void NativeConstruct() override;
 
     UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "ToolTip")
     bool SetToolTipTextDesign(FText ToolTip);
 };

ToolTipDesign.cpp

 #include "MyProject.h"
 #include "ToolTipDesign.h"
 
 void UToolTipDesign::NativeConstruct()
 {
     Super::NativeConstruct();
 
     SetToolTipTextDesign(MyToolTipText);
 }
 
 bool UToolTipDesign::SetToolTipTextDesign(FText ToolTip)
 {
 
     return false;
 }
 

The compile errors

Error C2511 'bool UToolTipDesign::SetToolTipTextDesign(const FText &)': overloaded member function not found in 'UToolTipDesign'

Error C2352 'UObject::FindFunctionChecked': illegal call of non-static member function

When I remove "UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "ToolTip")" the build errors go away however I an unable to override the function in blueprints.

Product Version: UE 4.14
Tags:
more ▼

asked Feb 17 '17 at 04:40 AM in C++ Programming

avatar image

zhegames
15 2 6 7

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

1 answer: sort voted first

In your header add one line so it looks like this (i believe this is optional, but I like it better to explicitly declare it):

  UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "ToolTip")
  bool SetToolTipTextDesign(const FText& ToolTip);
  bool SetToolTipTextDesign_Implementation(const FText& ToolTip);

In your cpp change the implemented function name to SetToolTipTextDesign_Implementation:

  bool UToolTipDesign::SetToolTipTextDesign_Implementation(const FText& ToolTip)
  {
       return false;
  }

For BlueprintNativeEvent, and others, the UHT generates code that implements SetToolTipTextDesign (because it needs to call blueprint), which calls the SetToolTipTextDesign_Implementation that you need to implement.

edit:

I also changed the FText parameters to const FText& (as it is best practice in c++), because the UHT seems to enforce this, and does not allow the FText by copy parameter.

Note that const reference and copy are semantically the same, const ref is usually faster.

more ▼

answered Feb 17 '17 at 06:33 PM

avatar image

Wurmloch83
581 14 12 37

avatar image zhegames Feb 18 '17 at 01:04 AM

When I put this into the code I'm getting the same errors word for word.

avatar image Wurmloch83 Feb 18 '17 at 08:25 AM

Yes, you are right, you need to use const FText& ToolTip instead of FText ToolTip Seems that the UHT enforces this, which I did not know. Updating the answer.

avatar image zhegames Feb 18 '17 at 08:35 AM

It worked thank you.

(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