2
\$\begingroup\$

I am trying to open a dialog to select files under UE4, using OpenFileDialog.

I added this to my build.cs

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "DesktopPlatform" });

In my header:

#include "IDesktopPlatform.h"
#include <Developer\DesktopPlatform\Private\Windows\DesktopPlatformWindows.h>

Second line suggested by IntelliSense...

I am adding dummy values to my code to start with:

void AFileDialogOpenerActor::OpenFileDialog() {         
    FString defaultFile = "";
    FString fileTypes = "";
    TArray<FString> outFileNames;       
    uint32 flags = 1;               
    FDesktopPlatformWindows fpl;
    fpl.OpenFileDialog(0, dialogName,defaultPath, defaultFile, fileTypes,flags, outFileNames);  
}

When I try to compile, I get these linker error messages:

linkingerrors

If I replace the above includes in the header to these:

#include "IDesktopPlatform.h"
#include "DesktopPlatformWindows.h"

In message log:

cannot open include file: "DesktopPlatformWindows.h" no such file or directory

If I play around with these includes, I get a mixture of these messages.(Either a linking error, either no such file, or the bunch of linking error messages) I took a look at containing folders of the headers and they are indeed there and public.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

After some searching I found this:

I my header I changed the includes to this:

#include "DesktopPlatform/Public/IDesktopPlatform.h"
#include "DesktopPlatform/Public/DesktopPlatformModule.h"

In the cpp:

IDesktopPlatform* fpl = FDesktopPlatformModule::Get();   
fpl->OpenFileDialog(0, dialogName, defaultPath, defaultFile, fileTypes, flags, outFileNames);

It looks like, I only needed a path to that header...

\$\endgroup\$
1
  • \$\begingroup\$ Note that answers to questions aren't the proper place for follow-up questions. For on-topic follow up questions, you should consider posting a new question. \$\endgroup\$ Commented Jul 3, 2020 at 9:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.