Hi everyone,

I'm developing an application using QML frontend with C++ backend. I have generated a plugin which was generated from C++ and I would now like to use this in Qml.

I believe I have imported the plugin correctly since when I run the program everything seems ok. So to clarify:

I Have a class called Box. I then have a class derived from QDeclarativeExtensionPlugin called BoxPlugin to expose the Box class to qml.

Qt Code:
  1. void BoxPlugin::registerTypes(const char *uri)
  2. {
  3. qmlRegisterType<Box>(uri, 1, 0, "Box");
  4. }
To copy to clipboard, switch view to plain text mode 

I then build the project with the following .pro file:

Qt Code:
  1. TEMPLATE = lib
  2. CONFIG += qt plugin
  3. QT += declarative
  4.  
  5. DESTDIR = plugin
  6. TARGET = boxPlugin
  7.  
  8. ... headers and source files
To copy to clipboard, switch view to plain text mode 

Then in main.c I import the plugin:
Qt Code:
  1. QPluginLoader loader("C:/Qt/myExamples/CppQmlProject/Src/Components/BasicComponents/plugin/boxPlugin.dll");
  2.  
  3. QDeclarativeExtensionPlugin *plugin = qobject_cast<QDeclarativeExtensionPlugin *>(loader.instance());
  4. if (plugin)
  5. plugin->registerTypes("BasicComponents.Boxes");
  6. else
  7. qDebug() << "FAIL!";
  8.  
  9. view->setSource(QUrl("MainWindow.qml"));
To copy to clipboard, switch view to plain text mode 

I run the application and everything works fine. However, and what makes things very confusing, is that in MainWindow.qml, all the references to Box appear as errors, so:

Qt Code:
  1. import BasicComponents.Boxes 1.0
  2.  
  3. Box {
  4. id: box
  5. }
To copy to clipboard, switch view to plain text mode 

Would be underlined with a syntax error and the tooltip will pop up with, "unknown type".

Now I think I understand what is happening: the program works because it imports the plugin and the references to Box get resolved at runtime. But how can I make my plugin visible to QtCreator? I assume its possible since we use QtQuick and its modules are visible.

I feel there something important I'm missing because I'm assuming these plugins are for reusing modules from project to project and currently I don't see how this is done without the project having a local copy of the plugin?

I'll end this already long post here, I hope someone can help clarify this for me!