QCoreApplication::instance() returning NULL

  • I am developing a plugin for an Qt application called Wireshark. The plugin is built into a Windows DLL that is detected at Wireshark startup time.

    I want to reference the QCoreApplication in the DLL. I've tried using QCoreApplication::instance() but it return a NULL pointer.

    The main application class is defined like this:

    class WiresharkApplication : public QApplication
        explicit WiresharkApplication(int &argc,  char **argv);

    And it's instantiated in main.

    I've read that there is a problem with QCoreApplication::instance() and release and debug builds - see http://www.qtcentre.org/archive/index.php/t-45574.html

    Is this an actual problem?

    I'm using Visual Studio 2013 to develop the code.

    Thanks and regards...Paul

  • Qt Champions 2017

    In fact this should not give the problem. It should return the right value object value. It does not matter from where you are calling. I have used this many times on linux and Mac, It works fine. I'm sure this will not help you. Can I send my simple plugin and app code which you can check ? Hope your plugin and exe are either in release or debug mode and NOT criss-crossed.

  • @dheerendra Hi - I might take you up on the offer of trying your code but let me try to fix what I have first. The build process for Wireshark is extremely complex and so I think I should check that I have criss crossed the build and debug status.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.