@jsulm Thank you very much.
Here is my button widget
import QtQuick 2.12
import QtQuick.Controls 2.12
Button {
id: button
/** sets Button Text visible*/
property bool bIsButtonTextVisible: true
....
Here is my CheckBox Widget
import QtQuick 2.0
import QtQuick.Controls 2.12
Rectangle{
id :checkBox
/** checkbox current state checked / unchecked */
property bool checked: true
...
Here is my cpp code
#include "widgets_plugin.h"
#include <qqml.h>
void WidgetsPlugin::registerTypes(const char *uri)
{
// @uri com.mycompany.qmlcomponents
qmlRegisterType(QUrl("qrc:/EDSButton/Source/component/ButtonWidget.qml"), uri, 1, 0, "ButtonWidget");
qmlRegisterType(QUrl("qrc:/EDSCheckBox/Source/component/CheckBoxWidget.qml"), uri, 1, 0, "CheckBoxWidget");
}
Here is my header file
#ifndef WIDGETS_PLUGIN_H
#define WIDGETS_PLUGIN_H
#include <QQmlExtensionPlugin>
class WidgetsPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char *uri) override;
};
#endif // WIDGETS_PLUGIN_H
All this packaged into a library.
Here is my application cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
And here is my main qml
import QtQuick 2.9
import QtQuick.Window 2.2
//import "qrc:/EDSCheckBox/Source/component"
import "C:\Users\RadiumBall\Downloads\EDSCheckBoxComponent\EDS_Component\debug\Widgets.dll"
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
CheckBoxWidget{
id : testCheckBox
rCheckboxConfigureHeight: 24
rCheckboxConfigureWidth: 24
rCheckboxConfigureRadius: 1
rCheckboxConfigureImgHeight: 16
rCheckboxConfigureImgWidth: 16
sCheckBoxLabel: "CheckBox"
}
I am doing two mistakes here, one is w.r.t importing the library and other complier throws me error 'CheckBoxWidget' is not a type.
PS: The CheckBoxWidget qml works perfectly fine when included directly but fails when included as a library.
Please help.