How to import Qml plugins lib into another project?

Multi tool use
Multi tool use





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















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.










share|improve this question

























  • show your MyPlugin,h

    – eyllanesc
    Jan 3 at 21:57











  • added .h details in the description

    – Rubina
    Jan 3 at 22:29











  • The easiest way to return custom component from a plugin is to use some factory method ie. you pass name of the component and receive QQuickItem-derived class. Btw, if you call in your app to regusterTypes the component should be visible in the QML code.

    – folibis
    Jan 4 at 8:39













  • @folibis Could you show an example how to achieve this ?

    – Rubina
    Jan 4 at 14:03











  • That depends on what you want to archive. Show the code where you instantiate the plugin.

    – folibis
    Jan 4 at 14:50


















0















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.










share|improve this question

























  • show your MyPlugin,h

    – eyllanesc
    Jan 3 at 21:57











  • added .h details in the description

    – Rubina
    Jan 3 at 22:29











  • The easiest way to return custom component from a plugin is to use some factory method ie. you pass name of the component and receive QQuickItem-derived class. Btw, if you call in your app to regusterTypes the component should be visible in the QML code.

    – folibis
    Jan 4 at 8:39













  • @folibis Could you show an example how to achieve this ?

    – Rubina
    Jan 4 at 14:03











  • That depends on what you want to archive. Show the code where you instantiate the plugin.

    – folibis
    Jan 4 at 14:50














0












0








0








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.










share|improve this question
















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.







qt qml qmake






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 4 at 15:30







Rubina

















asked Jan 3 at 21:48









RubinaRubina

5319




5319













  • show your MyPlugin,h

    – eyllanesc
    Jan 3 at 21:57











  • added .h details in the description

    – Rubina
    Jan 3 at 22:29











  • The easiest way to return custom component from a plugin is to use some factory method ie. you pass name of the component and receive QQuickItem-derived class. Btw, if you call in your app to regusterTypes the component should be visible in the QML code.

    – folibis
    Jan 4 at 8:39













  • @folibis Could you show an example how to achieve this ?

    – Rubina
    Jan 4 at 14:03











  • That depends on what you want to archive. Show the code where you instantiate the plugin.

    – folibis
    Jan 4 at 14:50



















  • show your MyPlugin,h

    – eyllanesc
    Jan 3 at 21:57











  • added .h details in the description

    – Rubina
    Jan 3 at 22:29











  • The easiest way to return custom component from a plugin is to use some factory method ie. you pass name of the component and receive QQuickItem-derived class. Btw, if you call in your app to regusterTypes the component should be visible in the QML code.

    – folibis
    Jan 4 at 8:39













  • @folibis Could you show an example how to achieve this ?

    – Rubina
    Jan 4 at 14:03











  • That depends on what you want to archive. Show the code where you instantiate the plugin.

    – folibis
    Jan 4 at 14:50

















show your MyPlugin,h

– eyllanesc
Jan 3 at 21:57





show your MyPlugin,h

– eyllanesc
Jan 3 at 21:57













added .h details in the description

– Rubina
Jan 3 at 22:29





added .h details in the description

– Rubina
Jan 3 at 22:29













The easiest way to return custom component from a plugin is to use some factory method ie. you pass name of the component and receive QQuickItem-derived class. Btw, if you call in your app to regusterTypes the component should be visible in the QML code.

– folibis
Jan 4 at 8:39







The easiest way to return custom component from a plugin is to use some factory method ie. you pass name of the component and receive QQuickItem-derived class. Btw, if you call in your app to regusterTypes the component should be visible in the QML code.

– folibis
Jan 4 at 8:39















@folibis Could you show an example how to achieve this ?

– Rubina
Jan 4 at 14:03





@folibis Could you show an example how to achieve this ?

– Rubina
Jan 4 at 14:03













That depends on what you want to archive. Show the code where you instantiate the plugin.

– folibis
Jan 4 at 14:50





That depends on what you want to archive. Show the code where you instantiate the plugin.

– folibis
Jan 4 at 14:50












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030270%2fhow-to-import-qml-plugins-lib-into-another-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030270%2fhow-to-import-qml-plugins-lib-into-another-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







b 2rPAB
zbi894JZTBJwi6Pl,W27Vm9Km5gd,Ih,waB8k6zFn7bS m,bm3d9LKcp

Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas