步骤:
1. 创建MFC-窗口(本例为Mfc对话框)
2. 新建一个线程用以运行QT窗口(可扩展进行消息响应,以创建QT窗口)
3.构建全局QApplication对象(本例临时构建)
代码如下:
#include <qtGui/qtgui>
#include <QtGui/QApplication>
#pragma comment(lib,"QtGuid4.lib")
#pragma comment(lib,"QtCored4.lib")
...
DWORD WINAPI QtBoot(LPVOID lpParameter)
{
int argc = 1;
TCHAR targv[MAX_PATH];
GetModuleFileName(NULL,targv,MAX_PATH);
USES_CONVERSION;
std::string strPath = T2A(targv);
char argv[MAX_PATH];
memcpy(argv,strPath.c_str(),strPath.length());
char* aargv = argv;
QApplication a(argc,&aargv );
QMessageBox dlg;
dlg.setIcon(QMessageBox::Question);
dlg.warning(0,QObject::tr("MFC&QT"),QObject::tr("I‘m Created By Mfc!"),QMessageBox::Ok);
return a.exec();
}
void CMfc_QtDlg::OnBnClickedBtnQt()//Mfc按钮事件
{
// TODO: 在此添加控件通知处理程序代码
CreateThread(NULL,0,QtBoot,NULL,NULL,NULL);
}
运行结果
原文地址:http://blog.csdn.net/gis_wudi/article/details/38981791