M
So to add the Qt library to UE4. I'll show you the example of Qt5Core.dll/libYou need msvc2017_64, which is indicated when QtCreator is installed and the Visual studio extension Qt VS ToolsEstablish UE4 using C+++In the Corne folder of the project to create additional folders
In this case, I've got follows:__From the root folder Qt move the required files:In my case, we're found in C:\Qt/Qt5.13.0\msvc2017_64\include\QtCoreand retrieve all the files in the [Brand folder of your project]/ ThirdParty/Qt/Includes/QtCore
In folder C:\Qt/Qt5.13.0\msvc2017_64\lib, we find Qt5Core.lib and Qt5Cored.liband copy to the [Brand folder of your project]/ThirdParty/Qt/Libraries/Win64In folder C:\Qt/Qt5.13.0\msvc2017_64\bin, we find Qt5Core.dll and Qt5Cored.liband copy to the [Brand folder of your project]/ThirdParty/Qt/Libraries/Win64Open your project through visual studio and find a file.
and change it. In this case, I have a project called InfProject2 to change the project name./ Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.using System.IO;
using UnrealBuildTool;
public class InfProject2 : ModuleRules
{
private string ModulePath
{
get { return ModuleDirectory; }
}
private string ThirdPartyPath
{
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../ThirdParty/")); }
}
public InfProject2(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "RHI", "RenderCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
PrivateIncludePaths.Add("D:/Program Files/Epic Games/UE_4.24/Engine/Source/Runtime/Launch/Public/");
LoadQt(Target);
/*
//Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
*/
}
public bool LoadQt(ReadOnlyTargetRules Target)
{
// Start OpenCV linking here!
bool isLibrarySupported = false;
// Create OpenCV Path
string QtPath = Path.Combine(ThirdPartyPath, "Qt");
// Get Library Path
string LibPath = "";
bool isdebug = Target.Configuration == UnrealTargetConfiguration.Debug;
if (Target.Platform == UnrealTargetPlatform.Win64)
{
LibPath = Path.Combine(QtPath, "Libraries", "Win64");
isLibrarySupported = true;
}
else
{
string Err = string.Format("{0} dedicated server is made to depend on {1}. We want to avoid this, please correct module dependencies.", Target.Platform.ToString(), this.ToString()); System.Console.WriteLine(Err);
}
if (isLibrarySupported)
{
//Add Include path
PublicIncludePaths.AddRange(new string[] { Path.Combine(QtPath, "Includes") });
// Add Library Path
PublicLibraryPaths.Add(LibPath);
//Add Static Libraries
PublicAdditionalLibraries.Add("Qt5Core.lib");
//Add Dynamic Libraries
PublicDelayLoadDLLs.Add("Qt5Core.dll");
}
PublicDefinitions.Add(string.Format("WITH_QT_BINDING={0}", isLibrarySupported ? 1 : 0));
return isLibrarySupported;
}
}
Create New Class C++ through Unreal Engine 4 and connect the library to the .cpp of the classed file.#include "QtCore/qstring.h"in designAOwlActorAndroid::AOwlActorAndroid()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
QString str = "QT";
GEngine -> AddOnScreenDebugMessage(-1, 5.f, FColor::Red, str.toStdString().c_str());
}
And look at the result. More information can be found here. https://www.ue4community.wiki/Legacy/Detailed_Account_Of_Integrating_OpenCV_Into_UE4_With_VS2017