PDA

View Full Version : QMainWindow as child of QWinWidget



Kaylx
16th March 2012, 11:30
Hey peeps,

Has anyone successfully used QMainWindow and QWinWidget together without issue?
I get problems with focus and activating the QMainWindow.
For example, sometimes a double click is needed, other times one click is needed, and other times (more often that not) I can't click on the window at all without clicking outside of the MFC app then clicking back on the QMainWindow. It appears parenting / ownership isn't quite right.

Here's the current code setup:


static QtModelviewer* gModelViewer = 0;

MODELVIEWER_C_EXPORT int OpenModelViewer( const LaunchParams& launchParams )
{
int retVal = -1;
if( QMfcApp::pluginInstance( launchParams.hInstance ) )
{
QWinWidget win( launchParams.hWndParent );
gModelViewer = new QtModelviewer( &win );
if( gModelViewer->loadModel( launchParams.filePath ) )
{
gModelViewer->show();
retVal = qApp->exec();
}
delete qApp;
gModelViewer = 0;
}
return retVal;
}

MODELVIEWER_C_EXPORT bool CloseModelViewer( )
{
if( gModelViewer )
{
qApp->quit();
return true;
}
return false;
}I've tried several things including 'How can I embed e.g a QMainWindow inside a QDialog ? (http://qt-project.org/faq/answer/how_can_i_embed_e.g_a_qmainwindow_inside_a_qdialog )' to no avail.