Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTplugin for beginner
Qt 6.11 is out! See what's new in the release blog

QTplugin for beginner

Scheduled Pinned Locked Moved Unsolved General and Desktop
44 Posts 5 Posters 17.5k Views 2 Watching
  • 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.
  • J Offline
    J Offline
    JadeN001
    wrote on last edited by JadeN001
    #1

    I am new in qTplugin.i dont know how to startup.i have followed https://doc-snapshots.qt.io/qtcreator-extending/first-plugin.html But i am getting error :
    mypluginplugin.h:5: error: extensionsystem/iplugin.h: No such file or directory

    What are extensionsystem & iplugin and how can i add it on my file.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Might be a silly question but what kind of plugin do you want to build ? For Qt Creator or for your application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Might be a silly question but what kind of plugin do you want to build ? For Qt Creator or for your application ?

        J Offline
        J Offline
        JadeN001
        wrote on last edited by
        #3

        @SGaist for my application.
        I read QT document about pugins but I'm not able to understand where to start, and how to add iplugin and extensionsystem.
        what type of project should I use , meaning from the scratch...NewProject->...?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then you are following the wrong guide. That's for Qt Creator plugins.

          Following this part of the documentation and the linked examples.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 2 Replies Last reply
          2
          • SGaistS SGaist

            Then you are following the wrong guide. That's for Qt Creator plugins.

            Following this part of the documentation and the linked examples.

            J Offline
            J Offline
            JadeN001
            wrote on last edited by
            #5

            @SGaist ohh thanks.i will go through it.

            1 Reply Last reply
            0
            • SGaistS SGaist

              Then you are following the wrong guide. That's for Qt Creator plugins.

              Following this part of the documentation and the linked examples.

              J Offline
              J Offline
              JadeN001
              wrote on last edited by
              #6

              @SGaist hey what is the difference between GUI and plugin.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                GUI: Graphical User Interface

                Plugin: add-on that implements features for an application/library without requiring to rebuild said library/application.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                J 1 Reply Last reply
                1
                • SGaistS SGaist

                  GUI: Graphical User Interface

                  Plugin: add-on that implements features for an application/library without requiring to rebuild said library/application.

                  J Offline
                  J Offline
                  JadeN001
                  wrote on last edited by JadeN001
                  #8

                  @SGaist thank you
                  So it mean if I have an application, lets say app-1 and I want to use app-2 in app-1 , so I need to create plugin of app-2 and add it to app-1?

                  aha_1980A mrjjM 2 Replies Last reply
                  0
                  • J JadeN001

                    @SGaist thank you
                    So it mean if I have an application, lets say app-1 and I want to use app-2 in app-1 , so I need to create plugin of app-2 and add it to app-1?

                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @JadeN001 said in QTplugin for beginner:

                    @SGaist thank you
                    So it mean if I have an application, lets say app-1 and I want to use app-2 in app-1 , so I need to create plugin of app-2 and add it to app-1?

                    Yes, that should work.

                    Qt has to stay free or it will die.

                    1 Reply Last reply
                    0
                    • J JadeN001

                      @SGaist thank you
                      So it mean if I have an application, lets say app-1 and I want to use app-2 in app-1 , so I need to create plugin of app-2 and add it to app-1?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      @JadeN001
                      Normally the story would be more like
                      App 1 has some features that App 2 could also use.
                      Then you take the features and put in plugin.
                      Now both apps can use the same code via the plugin.

                      Other use cases is that some features are not used all the time. So
                      putting them in a plugin, allows the app to start faster and first load the extra features when needed.

                      Other use case is some sort of base App. user can then get extra features via plugins.
                      Often the plugins could be made by other people than the programmer of the main app.

                      So its both a system for dividing the code to smaller blocks as not to have one BIG fat App.

                      Its also a way to allow external people to add features to your app , or allow you to have a base app and more features can be had via plugins. ( to make app extensible without having the source code )

                      1 Reply Last reply
                      4
                      • J Offline
                        J Offline
                        JadeN001
                        wrote on last edited by JadeN001
                        #11

                        I am trying to create a plugin of widget.
                        for that i have created 2 sub-projects. one is of widgets and second is of plugin. but i am not able to include header file of widget in to plugin.
                        so,how to include files into another project.

                        main project pro:
                        TEMPLATE = subdirs

                        SUBDIRS +=
                        pluginwidgets
                        plugin

                        I

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          JadeN001
                          wrote on last edited by
                          #12

                          Here another issue i'm facing ,I don't know exact reason behind it .
                          Getting error of :

                          ```'server_task' does not name a type
                               server_task* m_server;
                               ^
                          
                          mainwindow.h file :
                          
                          
                          #ifndef MAINWINDOW_H
                          #define MAINWINDOW_H
                          
                          #include <QMainWindow>
                          #include<QWidget>
                          #include"server_task.h"
                          #include"broadcastmsg.h"
                          namespace Ui {
                          class MainWindow;
                          }
                          
                          class MainWindow : public QMainWindow
                          {
                              Q_OBJECT
                          
                          public:
                              explicit MainWindow(QWidget *parent = 0);
                              ~MainWindow();
                              void addmessage(QString msg);
                          private slots:
                              void on_pushButton_Start_clicked();
                          
                              void on_actionSendToAll_triggered();
                          
                          private:
                              Ui::MainWindow *ui;
                              BroadCastmsg *b;
                              server_task* m_server;
                          
                          };
                          
                          #endif // MAINWINDOW_H
                          
                          
                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            JadeN001
                            wrote on last edited by
                            #13

                            okay,my problem is solved.i have to just declare class name
                            class server_task before
                            class maiwindow
                            {
                            }

                            class server_task;    //  <------here
                            class MainWindow : public QMainWindow
                            {....
                            .....
                            }
                            

                            But i don't know why it is required because i have already include header file of it.

                            1 Reply Last reply
                            0
                            • mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              Hi
                              To declare
                              server_task* m_server;

                              it needs to have seen type/class server_task
                              either via
                              class server_task; // forwarding
                              or
                              #include "server_task.h"

                              J 1 Reply Last reply
                              0
                              • mrjjM mrjj

                                Hi
                                To declare
                                server_task* m_server;

                                it needs to have seen type/class server_task
                                either via
                                class server_task; // forwarding
                                or
                                #include "server_task.h"

                                J Offline
                                J Offline
                                JadeN001
                                wrote on last edited by
                                #15

                                @mrjj It means that only including header file "server_task.h" it should work.if so,it does not work in my case.I have to add :

                                class server_task;
                                
                                mrjjM 1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  JadeN001
                                  wrote on last edited by
                                  #16
                                   Error: Plugin Metadata file "broadcastplugin.json" does not exist. Declaration will be ignored
                                  
                                  plugin.h
                                  
                                  #ifndef BROADCAST_PLUGIN_H
                                  #define BROADCAST_PLUGIN_H
                                  #include<QObject>
                                  #include<QString>
                                  #include"C:\Users\Kits\Documents\ServerWithPlugin\Server/interface_broadcast.h"
                                  class broadcast_Plugin:public QObject,interface_broadcast
                                  {
                                      Q_OBJECT
                                      Q_PLUGIN_METADATA(IID "org.qt-project.Qt.BroadcastInterface" FILE "broadcastplugin.json")
                                      Q_INTERFACES(interface_broadcast)
                                  
                                  public:
                                      broadcast_Plugin();
                                      void sendmsg(QString msg) override;
                                  signals:
                                      void sendToALL(QString m);
                                  
                                  };
                                  
                                  #endif // BROADCAST_PLUGIN
                                  
                                  plugin.pro file:
                                  #! [0]
                                  TEMPLATE        = lib
                                  CONFIG         += plugin
                                  QT             += widgets
                                  INCLUDEPATH    += ../echowindow
                                  HEADERS         = echoplugin.h
                                  SOURCES         = echoplugin.cpp
                                  TARGET          = $$qtLibraryTarget(echoplugin)
                                  DESTDIR         = ../plugins
                                  #! [0]
                                  
                                  EXAMPLE_FILES = broadcastplugin.json
                                  
                                  # install
                                  target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/echoplugin/plugins
                                  INSTALLS += target
                                  
                                  CONFIG += install_ok  # Do not cargo-cult this!
                                  
                                  
                                  1 Reply Last reply
                                  0
                                  • J JadeN001

                                    @mrjj It means that only including header file "server_task.h" it should work.if so,it does not work in my case.I have to add :

                                    class server_task;
                                    
                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by mrjj
                                    #17

                                    @JadeN001

                                    well its never needed with both. ever :)
                                    so something else.

                                    regarding:
                                    broadcastplugin.json
                                    you have to make it yourself.

                                    J 1 Reply Last reply
                                    0
                                    • mrjjM mrjj

                                      @JadeN001

                                      well its never needed with both. ever :)
                                      so something else.

                                      regarding:
                                      broadcastplugin.json
                                      you have to make it yourself.

                                      J Offline
                                      J Offline
                                      JadeN001
                                      wrote on last edited by
                                      #18

                                      @mrjj I am new in this area,so can u guide me how to create a .json file!

                                      1 Reply Last reply
                                      0
                                      • J Offline
                                        J Offline
                                        JadeN001
                                        wrote on last edited by
                                        #19

                                        I am really stuck in plugin.Can anyone suggest me the basic video/guideline of how to start with plugin for application. As based on qt documentation "echo-plugin" example
                                        http://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html.
                                        As a main project, which type of project should be chosen.how to create .json file for echo plugin(from QT Examples) which type of project I should choose. I am not getting clear idea from qt documentation.
                                        Currently I am using "empty Qmake project " for echoplugin .

                                        mrjjM 1 Reply Last reply
                                        0
                                        • J JadeN001

                                          I am really stuck in plugin.Can anyone suggest me the basic video/guideline of how to start with plugin for application. As based on qt documentation "echo-plugin" example
                                          http://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html.
                                          As a main project, which type of project should be chosen.how to create .json file for echo plugin(from QT Examples) which type of project I should choose. I am not getting clear idea from qt documentation.
                                          Currently I am using "empty Qmake project " for echoplugin .

                                          mrjjM Offline
                                          mrjjM Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          @JadeN001
                                          Just create the .json file
                                          echoplugin.json
                                          only contains {} ( empty json object ) and
                                          that prevents the warning.

                                          You can use any template for plugin but "empty Qmake project " should be fine, but make sure you
                                          add the needed stuff in .pro
                                          most critical being
                                          TEMPLATE = lib
                                          CONFIG += plugin

                                          There is also the old sample
                                          https://doc.qt.io/archives/qt-5.10/qtwidgets-tools-plugandpaint-plugins-basictools-example.html
                                          That shows a paint program that uses plugins to add brushes and pens. Not sure why its retired.

                                          why not copy echo sample and just change names ?
                                          Most plugin code is the same for all plugins.
                                          The only part that differ is names and and the actual feature code of the plugin. (what it does)

                                          J 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