简体   繁体   English

非Qt应用程序中的QT dll

[英]QT dll in non-qt application

I have some problems to distribute my QT class (5.7, msvc) to other developer (He uses borland C++ builder). 我在将我的QT类(5.7,msvc)分发给其他开发人员时遇到了一些问题(他使用borland C ++构建器)。 While loading, my dll application can't find platforms\\qwindows.dll 加载时,我的dll应用程序找不到platforms\\qwindows.dll

Can anybody tell me (with examples) how to create dll and use it in other compilers? 谁能告诉我(带有示例)如何创建dll并在其他编译器中使用它?

This is my way to export some class methods: 这是我导出某些类方法的方法:

#include <string>
#include <QString>
#include "dialog.h"
dialog* dlg;

extern "C" __declspec(dllexport) void DLLInit() {
    int argcc = 0;
    new QApplication(argcc, 0, false);
    dlg = new dialog();
}

extern "C" __declspec(dllexport) void DLLDestroy() {
    delete dlg;
    delete qApp;
}

extern "C" __declspec(dllexport) void setText(std::wstring str){
    dlg->setText(QString::fromWCharArray(str.c_str()));
}

extern "C" __declspec(dllexport) int add(int a, int b){
    return dlg->add(a, b);
}

The file structure seems correct ( qt_form is my dll): 文件结构似乎正确( qt_form是我的dll):

文件结构似乎正确:

If the EXE is not in the same folder as the Qt libraries, have the EXE call SetDllDirectory with the path of the folder containing your DLL and Qt DLLs. 如果EXE与Qt库不在同一个文件夹中,请EXE调用SetDllDirectory,并在其中包含DLL和Qt DLL的文件夹路径。

Or ammend the PATH environment variable to include this folder. 或修改PATH环境变量以包含此文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM