I have a 2 qml files in a lib and I want to export those to another project and was unable to import in my QuickQmlTest project. I want to use those qml files from QmlPlugin lib in QuickQmlTest project. Is there any additional step I need to do ? I have a folder structure
QMLProject
|-- QmlPlugin -(it is lib)
|--QML
|--CustomButton.qml
|-- CustomPolygon.qml
|-- QuickQmlTest - (app)
My QmPlugins.pro looks like this
TEMPLATE = lib
TARGET = QmlPlugin
QT += qml quick
CONFIG += plugin c++11
TARGET = $$qtLibraryTarget($$TARGET)
HEADERS += \
MyPlugin.h
DISTFILES = qmldir \
CustomButton.qml \
CustomPolygon.qml
DESTDIR = $$PWD/lib
And I linked the generated dlls into to the QuickQmlTest.pro using
LIBS += -L$$PWD/../QmlPlugin/lib -lQmlPlugin
INCLUDEPATH += $$PWD/../QmlPlugin
MyPlugin.h
#include <QQmlExtensionPlugin>
#include <QtQml/qqml.h>
class MyItemModel: public QObject
{
Q_OBJECT
Q_PROPERTY(qreal roundingRadius READ roundingRadius WRITE setRoundingRadius)
public:
void setRoundingRadius(const qreal rounding)
{
roundingRadius_ = rounding;
}
qreal roundingRadius() const
{
return roundingRadius_;
}
private:
qreal roundingRadius_{8.0};
};
class MyPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char* uri)override
{
Q_ASSERT(uri == QLatin1String("Components"));
qmlRegisterType<MyItemModel>(uri, 1, 0, "MyItemModel");
}
};
in qmldir I have
module Components
Components 1.0 CustomButton.qml CustomPolygon.qml
plugin QmlPlugin
In the QuickQmlTest (app)
I want to use CustomButton.qml and CustomPolygon.qml in my main.qml
So my main.qml in QuickQmlTest app
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import Components 1.0 //To import the dll from lib
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
CustomPolygon
{
width:60
height:30
}
CustomButton
{
width:60
height:30
}
}
And also I want to see my Custom qml types(CustomButton and CustomPolygon) in Quick Design mode which I am unable to achieve.