title: QPluginLoader instance always returns null
body: <p>I am in the process of building a Qt application. While I have programmed lots of GUI things before and the framework itself isn't presenting a problem, I have not ever programmed anything (outside of C# .NET applications) that has the capability to load plugins. The project I am trying to build has plugins as an integral part of it and I thought the Qt framework looked nice for this because it was almost universally cross-platform and seems to have a very nice system for plugins.</p>
  
  <p>My problem is this: <em>I can't seem to get the QPluginLoader.instance() method to return anything but a null value</em>.</p>
  
  <p>From my readings, this is because it finds no plugin. I think I am probably forgetting to do something, but I can find very little documentation on actually writing plugins (there are examples, but they aren't incredibly detailed). There are plenty of examples of loading plugins and I think I am doing that right, but I haven't really found an example of actually making a plugin.</p>
  
  <p>This is what I have done:</p>
  
  <p>Using Qt-Creator I have created two projects: A windowed application to pretend that it is my plugin receiving application and a Shared Library project to pretend to be the plugin</p>
  
  <p>In my windowed application I have a header file as follows:</p>
  
  <pre><code>#ifndef PLUGININTERFACE_H
  #define PLUGININTERFACE_H
  
  #include &lt;QtPlugin&gt;
  
  class QStringList;
  
  class PluginInterface
  {
  public:
      virtual ~PluginInterface() {};
  
      virtual QStringList messages() const = 0;
  };
  
  Q_DECLARE_INTERFACE(PluginInterface,
                      "com.kevincuzner.LearningPlugins.PluginInterface/1.0")
  
  #endif // PLUGININTERFACE_H
  </code></pre>
  
  <p>In my shared library application I created a class called ATestPlugin (and this is also the TARGET value of the project):</p>
  
  <pre><code>#ifndef ATESTPLUGIN_H
  #define ATESTPLUGIN_H
  
  #include "ATestPlugin_global.h"
  #include "../LearningPlugins/PluginInterface.h"
  
  #include &lt;QStringList&gt;
  
  
  class ATESTPLUGINSHARED_EXPORT ATestPlugin : public PluginInterface, public QObject
  {
  
      Q_OBJECT
      Q_INTERFACES(PluginInterface)
  
  public:
      ATestPlugin();
  
      virtual QStringList messages() const
      {
          //this part is actually defined in the .cpp file, but I don't feel like pasting that here
          QStringList ret;
          ret &lt;&lt; "foo" &lt;&lt; "bar" &lt;&lt; "noms" &lt;&lt; "Hello";
  
          return ret;
      }
  };
  
  #endif // ATESTPLUGIN_H
  </code></pre>
  
  <p>At the end of the ATestPlugin.cpp file I have placed <code>Q_EXPORT_PLUGIN2(ATestPlugin, ATestPlugin)</code></p>
  
  <p>Then in my main.cpp file in the main method I do the following (&amp;w points to the main window):</p>
  
  <pre><code>QString text = QFileDialog::getOpenFileName(&amp;w, "Get a file");
  QPluginLoader loader(text);
  QObject* plugin = loader.instance();
  if (plugin)
  {
      QMessageBox msgBox;
      msgBox.setText(text);
      msgBox.exec();
  }
  </code></pre>
  
  <p>When I run the program and select libATestPlugin.so from the build directory of my library project in the file dialog that pops up, I see no message box which means *plugin is null. Previously I had the messagebox always pop up and show the selected file name, so I know that part is working.</p>
  
  <p>Does anyone have any ideas as to what I need to do to make my plugin visible to QPluginLoader?</p>