Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4008084
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:42:38+00:00 2026-05-20T08:42:38+00:00

I’m using the Qt/MFC Migration Framework tool following this example: http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.html The dll I

  • 0

I’m using the Qt/MFC Migration Framework tool following this example:
http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.html

The dll I build is loaded by a 3rd party MFC-based application. The 3rd party app basically calls one of my exported DLL functions to startup my plugin and another function to shutdown my application. Currently I’m doing nothing in my shutdown function.

When I load my DLL in the 3rd party app the startup function is called and my DLL starts successfully and I can see my message box. However if I shutdown my plugin and then try to start it again I get the following error:

Debug Error!

Program: <my 3rd party app>
Module: 4.7.1
File: global\qglobal.cpp
Line: 2262
ASSERT failure in QWidget: "Widgets must be created in the GUI
thread.", file kernel\qwidget.cpp line 1233

(Press Retry to debug the application)

Abort Retry Ignore

This makes me think I’m not doing something to properly shutdown my plugin. What do I need to do to shut it down properly?

UPDATE:
http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-walkthrough.html says:

The DLL also has to make sure that it
can be loaded together with other Qt
based DLLs in the same process (in
which case a QApplication object will
probably exist already), and that the
DLL that creates the QApplication
object remains loaded in memory to
avoid other DLLs using memory that is
no longer available to the process.

So I wonder if there is some problem where I need to somehow keep the original DLL loaded no matter what?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:42:39+00:00Added an answer on May 20, 2026 at 8:42 am

    I GOT THIS WORKING! After many frustrating hours working on this I got it working. I was using the code provided in the Qt/MFC Migration documentation which has:

     BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason,
                          LPVOID /*lpvReserved*/ )
     {
         static bool ownApplication = FALSE;
    
         if ( dwReason == DLL_PROCESS_ATTACH )
             ownApplication = QMfcApp::pluginInstance( hInstance );
         if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
             delete qApp;
    
         return TRUE;
     }
    

    This structure would work for a single load of my plugin DLL, but failed on subsequent loads. I don’t believe DllMain is the correct place to call pluginInstance (at least for my use-case). I think the problem was that my 3rd party app only calls DllMain a single time and does not unload the DLL until the application quits. Thus when I started my plugin and then shut it down and then started it again, the QApplication initialized by the call to pluginInstance was still hanging around. I think my 3rd party app starts separate threads each time my plugin is started up, so when I started my plugin the second time it was a new thread but still trying to use the original QApplication setup in DllMain (the DLL still being loaded). Hence my error because it was new thread trying to write to the GUI.

    The 3rd party MFC app which I am building expects two exports in my DLL, Startup() and Shutdown(), which it calls at the relevant times.

    So instead of doing what the walkthrough suggests, I did as follows (pseudocode):

    extern "C" __declspec(dllexport) void Startup()
    {
      QMfcApp::pluginInstance( 3rdPartyApp::GetPluginHandle() );
      QWinWidget win( 3rdPartyApp::GetParentWindow() );
      win.showCentered();
      QMessageBox::about( &win, "About", "Hello World" );
    }
    
     extern "C" __declspec(dllexport) void Shutdown()
    {
      qApp->quit();
      delete qApp;
    }
    

    This is fine for a single plugin, but if I create multiple plugin’s I’m not sure how well this will work because of the event loop integration I think there should only be a single QApplication across all plugins (based on my reading of the Qt/MFC documentation).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.