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:


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.


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...

  • \$\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\$
    – Tyyppi_77
    Jul 3 '20 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.