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.
@//ExportMe.h
#define EXPORT_THIS Q_DECL_EXPORT
class ExportMeClass : public QWidget {
Q_OBJECT
public:
EXPORT_THIS MyConstructor(QWidget *parent = 0, Qt::WFlags flags = 0);
~MyConstructor();
};//ExportMe.cpp
#include "ExportMe.h"
extern "C" {
ExportMe::MyConstructor(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags) {
ui.setupUi(this);
}
ExportMe::~MyConstructor() {}
}//main.cpp
#include "ExportMe.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
ExportMe e;
e.show();
return a.exec();
}@New Project
@//IntegratedProj.cpp
#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:
- 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).
- 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?
-