Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Plugin type not recognized
Forum Updated to NodeBB v4.3 + New Features

Plugin type not recognized

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 510 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RadiumBall
    wrote on last edited by
    #1

    Hi,
    I am trying to build a simple plugin with multiple components Button, Checkbox etc. But When I try to use this plugin library in an application I get error "Widget is not a Type". Also please help with importing the plugin correctly.

    Thank you,
    Ashwin

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RadiumBall
      wrote on last edited by
      #2

      Here is the file https://easyupload.io/fd9c5b

      jsulmJ 1 Reply Last reply
      0
      • R RadiumBall

        Here is the file https://easyupload.io/fd9c5b

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @RadiumBall Please show the code where you load and use the plug-in.
        "Widget is not a Type" - this means that Widget is not known to the compiler - did you forget to include the header file where Widget is declared?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        R 1 Reply Last reply
        0
        • jsulmJ jsulm

          @RadiumBall Please show the code where you load and use the plug-in.
          "Widget is not a Type" - this means that Widget is not known to the compiler - did you forget to include the header file where Widget is declared?

          R Offline
          R Offline
          RadiumBall
          wrote on last edited by RadiumBall
          #4

          @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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved