Important: Please read the Qt Code of Conduct -

Change Standalone Qt App into Plugin for VS Project

  • Using Visual Studio 2008 with the Qt VS add-in, I built a standalone Qt application. Now I want to change its build so another VS project can use it as a plug-in.

    class ExportMeClass : public QWidget {
    EXPORT_THIS MyConstructor(QWidget *parent = 0, Qt::WFlags flags = 0);

    #include "ExportMe.h"
    extern "C" {
    ExportMe::MyConstructor(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags) {
    ExportMe::~MyConstructor() {}

    #include "ExportMe.h"
    #include <QtGui/QApplication>
    int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    ExportMe e;;
    return a.exec();

    New Project

    #include "ExportMe.h"
    IntegratedProj::MyConstructor(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags) {
    ExportMe::MyConstructor(parent, flags);

    The Problem

    The combined project does not run the plug-in. I have tried the following:

    1. Left the Project Properties the same for both projects, only adding Linker dependencies to IntegratedProj. This produced ExportMe.lib and ExportMe.exe. When I run depends.exe on IntegratedProj.exe, it requires the ExportMe.exe to be in the same directory. This allowed the IntegratedProj to recognize the plug-in, but it did not display the form file (UI). Prefer if final solution does not require adding the ExportMe executable to the IntegratedProj directory (prefer to share a dll).
    2. Changed the Project Properties for ExportMe project so it's General Configuration Type was set to .dll and the Linker Output File was set to .dll. This fails to compile due to Linker error (it cannot find the ExportMe.lib file). This Build configuration does not create a lib file though.

    How can I modify my solution, either in code or Build Properties, to turn the standalone Qt application into a plug-in for a Visual Studio project?

  • How about creating a separate project for your dll/lib?
    An additional project for your ExportMe.exe. The second project will certainly have to access the dll/lib.

    Depending on the size of the dll/lib part this may be the fastest way to get to a solution.

Log in to reply