当前位置:网站首页>MFC集成qt验证及问题处理
MFC集成qt验证及问题处理
2022-07-29 05:08:00 【longlongway2012】
MFC集成QT
MFC集成qt网上已经有很多例子,我在这里只是记录下我验证过程中遇到的问题,以便同样问题的人不再碰壁。
1. 单独创建一个mfc dll 无法导出
QWinWidget类和 QmfcApp类中使用QT_QTWINMIGRATE_EXPORT导出,但总是输出的不全,后来自己定义独立的导出而不用原定义的宏
#ifdef QGUI_EXPORTS
#define QGUI_API __declspec(dllexport)
#else
#define QGUI_API __declspec(dllimport)
#endif
2. 创建MFC程序后,他引用Qt文件就报错
错误 C2061 语法错误: 标识符“n”
原来MFC每个cpp文件中都对new进行了重载:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
从而导致一下代码中 new的执行调用错误:
QT_TRY {
while(current != to) {
new (current) T(*reinterpret_cast<T*>(src));
++current;
++src;
}
3. 生成QT项目后,无法运行
生成后需要使用windeployqt进行发布,但我发布后仍然无法运行,参考别的博客,原来是qtplugin需要配置环境变量
错误如下:
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
添加环境变量:
QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%/plugins
4. mfc使用多字节时输入框乱码:
默认使用宽字节,mfc输入框没问题,当改为多字节就出现乱码,后来发现,可以不适用qMfcApp::run,消息也可以正确路由:
int CMFCQtDlgTestApp::Run()
{
MainQTFrame mainUI;
mainUI.show();
//return QMfcApp::run(this);
return CWinAppEx::Run();
}
参考网站:
边栏推荐
猜你喜欢
随机推荐
Is Huatai Securities an AA level securities company? How about this company? Is it safe to open an account?
关于thymeleaf的配置与使用
On AspectJ framework
How to solve the problem of configuring the progress every time Office2010 is opened?
C 语言手写 QQ-AI 版
Teardown 解除时间限制的方法
Understand activity workflow
玩家访问网站自动弹窗加QQ群方法以及详细代码
6.3 references
The representation of time series analysis: is the era of learning coming?
传奇如何一台服务器配置多个版本微端更新
Northeast University Data Science Foundation (matlab) - Notes
Database course design of online assistant teaching platform for high school chemistry
Force deduction ----- sort odd and even subscripts respectively
Let you understand several common traffic exposure schemes in kubernetes cluster
The song of the virtual idol was originally generated in this way!
js(forEach)出现return无法结束函数的解决方法
The method and detailed code of automatically pop-up and QQ group when players visit the website
ARFoundation从零开始5-AR图像跟踪
Solve the warning prompt of MySQL mapping file









