Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Change Standalone Qt App into Plugin for VS Project

    General and Desktop
    2
    2
    1778
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      ReaMix last edited by

      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:

      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?

      1 Reply Last reply Reply Quote 0
      • K
        koahnig last edited by

        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.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 0
        • First post
          Last post