Qt:如何创建Windows DLL(导出函数)?
我需要创建一个导出函数并具有图形用户界面的 Windows DLL。 GUI 位于 DLL 中的原因是 DLL 充当其他第 3 方应用程序的一种插件。目前我只能访问 Visual Studio Express,据我所知它不支持 MFC,所以我正在寻找在 DLL 中创建 GUI 的替代方法。经过一番研究后,我发现了 Qt,它看起来很有前途。看起来使用 Qt Creator IDE 可能比使用 Visual Studio Express 更容易。
但是,如何在 Qt Creator 中创建 Windows DLL? (我猜是常规 DLL,我不认为 COM 或托管 DLL 可以工作)
更新: 我成功了!经过几道坎之后,添加了两个重要的关键
#include <windows.h>
,然后使用 Qt/MFC 迁移框架工具(目前官方提供:http://qt.gitorious.org/qt-solutions/qt-solutions/trees/master/qtwinmigrate 编辑:我相信这是新链接: https://github.com/qtproject /qt-solutions/tree/master/qtwinmigrate)
我用这个例子来让我继续:
http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.html
I need to create a windows DLL that exports functions and has a graphical user interface. The reason for the GUI in the DLL is that the DLL serves as a kind of plugin for another 3rd party application. Currently I only have access to Visual Studio Express which AFAIK doesn't support MFC so I'm looking for alternative ways to create a GUI in a DLL. After some research I came across Qt which seems promising. And it seems like it might be easier to just use the Qt Creator IDE rather than Visual Studio Express.
However, how do I create a windows DLL in Qt Creator? (I guess a regular DLL, I don't think a COM or managed DLL will work)
UPDATE:
I got this working! After jumping through several hoops, two important keys were to add
#include <windows.h>
And then to use the Qt/MFC Migration Framework tool (currently officially available at: http://qt.gitorious.org/qt-solutions/qt-solutions/trees/master/qtwinmigrate EDIT: I believe this is the new link: https://github.com/qtproject/qt-solutions/tree/master/qtwinmigrate)
I used this example to get me going:
http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.html
EDIT: I believe this is the new link http://htmlpreview.github.io/?https://github.com/qtproject/qt-solutions/blob/master/qtwinmigrate/doc/html/winmigrate-qt-dll-example.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将以下行添加到 .pro 文件中:
TEMPLATE = lib
这就是让 QtCreator 将您的“应用程序”制作成 dll 所需要做的全部工作。
Add the folowing line to the .pro file:
TEMPLATE = lib
That's just about all you'll have to do to have QtCreator make your 'app' into a dll.
检查qt插件 http://cartan.cas.suffolk.edu/qtdocs/plugins- howto.html
check qt plugins http://cartan.cas.suffolk.edu/qtdocs/plugins-howto.html