Hello
I am using
- Qt 4.5 opensource
- Qt/Mfc migration Framework. (open source edition)
I want to make qt gui dll that will be loaded in non qt existing application for which I don't have source code.
the code for the dll :
#include <qmfcapp.h>
#include <qwinwidget.h>
#include <QtGui/QMessageBox>
BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID )
{
static bool ownApplication = FALSE;
if ( dwReason == DLL_PROCESS_ATTACH )
ownApplication = QMfcApp::pluginInstance( hInstance );
if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
delete qApp;
return TRUE;
}
void showqt(HWND parent)
{
QWinWidget* win=new QWinWidget( parent );
win->showCentered();
Ui::GoToCellDialog ui;
ui.setupUi(dialog);
dialog->show();
return ;
}
#include <qmfcapp.h>
#include <qwinwidget.h>
#include <QtGui/QMessageBox>
BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID )
{
static bool ownApplication = FALSE;
if ( dwReason == DLL_PROCESS_ATTACH )
ownApplication = QMfcApp::pluginInstance( hInstance );
if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
delete qApp;
return TRUE;
}
void showqt(HWND parent)
{
QWinWidget* win=new QWinWidget( parent );
win->showCentered();
Ui::GoToCellDialog ui;
QDialog *dialog = new QDialog(win);
ui.setupUi(dialog);
dialog->show();
return ;
}
To copy to clipboard, switch view to plain text mode
The problem is that the dialog is not shown at all, or sometimes it
is shown and very quickly disappears . Note that when I am trying to use modal dialog (dialog->exec()) the dialog is shown .
Maybe that is cause modal dialog has its own message loop,
but i was expecting this will work cause I am merging the application loop with the qt loop with QMfcApp:: pluginInstance.
Form the documentation :
"The QMfcApp class also provides a static API pluginInstance() that drives the Qt event loop when loaded into an MFC or Win32 application. This is useful for developing Qt based DLLs or plugins, or if the MFC application's event handling can not be modified."
Thanks
Bookmarks