MFC and QT message loop mechanism is different, so, to let Qt write DLL can be called by MFC, to do a bit of special processing
[CPP]View Plaincopyprint?
- #include <qmfcapp.h>
- #include <qwinwidget.h>
- #include <QtGui>
- #include <QtGui/QMessageBox>
- #include <windows.h>
- #include <QTextCodec>
[CPP]View Plaincopyprint?
- #include "Widget.h"
- BOOL WINAPI DllMain ( hinstance hinstance, DWORD dwreason, lpvoid /*lpvreserved*/)
- {
- static bool ownapplication = FALSE;
- //Join local language support
- QTEXTCODEC::SETCODECFORTR (Qtextcodec::codecforlocale ());
- Qtextcodec::setcodecforcstrings (Qtextcodec::codecforlocale ());
- if (Dwreason = = Dll_process_attach)
- {
- Ownapplication = Qmfcapp::p lugininstance (HINSTANCE);
- }
- if (Dwreason = = Dll_process_detach && ownapplication)
- {
- Qapp->quit ();
- Delete Qapp;
- }
- return TRUE;
- }
- extern "C" __declspec (dllexport) int ShowDialog ( HWND parent)
- {
- Qwinwidget win (parent, NULL, Qt::window);
- Win.showcentered ();
- Win.center ();
- Qhboxlayout Hbox (&win);
- Widget *widget = new Widget (&win);
- Widget->setwindowflags (Qt::window);
- Hbox.addwidget (widgets);
- Win.show ();
- Qapp->exec ();
- }
http://blog.csdn.net/small_qch/article/details/6743803
A QT-Implemented DLL (Qtwinmigrate implementation) that can be called by MFC