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. how the functions of QanalogClockPlugin has been called in qwidgetplugins.
Forum Updated to NodeBB v4.3 + New Features

how the functions of QanalogClockPlugin has been called in qwidgetplugins.

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 4 Posters 2.3k 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.
  • H Offline
    H Offline
    hjohn
    wrote on 20 Jun 2018, 10:13 last edited by
    #1

    http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html
    In this example they have defined all the function in QanalogClockPlugin class .but I don't have any idea from where they are called ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Jun 2018, 10:27 last edited by
      #2

      Hi,

      It's a Designer plugin. Everything is explained on the page you linked under AnalogClockPlugin Implementation.

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

      H 1 Reply Last reply 20 Jun 2018, 10:32
      1
      • S SGaist
        20 Jun 2018, 10:27

        Hi,

        It's a Designer plugin. Everything is explained on the page you linked under AnalogClockPlugin Implementation.

        H Offline
        H Offline
        hjohn
        wrote on 20 Jun 2018, 10:32 last edited by
        #3

        @SGaist yeah thanks..they have implement the function but from where that functions are being called.
        and last question how Qdesigner is deffer from the normal .ui application

        M 1 Reply Last reply 20 Jun 2018, 20:21
        0
        • H hjohn
          20 Jun 2018, 10:32

          @SGaist yeah thanks..they have implement the function but from where that functions are being called.
          and last question how Qdesigner is deffer from the normal .ui application

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 20 Jun 2018, 20:21 last edited by mrjj
          #4

          @hjohn
          Hi
          For a Designer plugin. The Designer app load the plugin and calls the methods to
          get name of the plugin/widgets and other metadata to show in its Widget list so
          they can be using while designing. So those functions are being called when the plugin is being loaded by Designer. ( or the loader part)

          QDesigner is a normal application. Nothing special there.
          However, it expects its plugins to have a certain interface/list
          of functions to return the data it wants.
          The most important being:
          QString includeFile() const override; / what include file to use in the UI code gen.
          QString name() const override; // what name to list it under in Widget List
          QWidget *createWidget(QWidget *parent) override; // ask it to supply a instance to put on form

          For your own application, a plugin could have any interface as you then decide the
          rules for being a plugin to your application.

          H 1 Reply Last reply 21 Jun 2018, 06:51
          1
          • M mrjj
            20 Jun 2018, 20:21

            @hjohn
            Hi
            For a Designer plugin. The Designer app load the plugin and calls the methods to
            get name of the plugin/widgets and other metadata to show in its Widget list so
            they can be using while designing. So those functions are being called when the plugin is being loaded by Designer. ( or the loader part)

            QDesigner is a normal application. Nothing special there.
            However, it expects its plugins to have a certain interface/list
            of functions to return the data it wants.
            The most important being:
            QString includeFile() const override; / what include file to use in the UI code gen.
            QString name() const override; // what name to list it under in Widget List
            QWidget *createWidget(QWidget *parent) override; // ask it to supply a instance to put on form

            For your own application, a plugin could have any interface as you then decide the
            rules for being a plugin to your application.

            H Offline
            H Offline
            hjohn
            wrote on 21 Jun 2018, 06:51 last edited by
            #5

            @mrjj it meaans by using functions like name() and CreatWidget() ,plugin connect with that particular widget.
            if so,then if i want to add another widget then i have to just add new values in these two functions.

            QString widgetPlugins::domXml() const{}
            

            Is this function important to implement.?

            M 1 Reply Last reply 21 Jun 2018, 06:59
            0
            • H hjohn
              21 Jun 2018, 06:51

              @mrjj it meaans by using functions like name() and CreatWidget() ,plugin connect with that particular widget.
              if so,then if i want to add another widget then i have to just add new values in these two functions.

              QString widgetPlugins::domXml() const{}
              

              Is this function important to implement.?

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 21 Jun 2018, 06:59 last edited by
              #6

              @hjohn

              Hi
              All the functions showed must be implemented.
              Its not optional. All must be implemented.

              Its possible to have same plugin offer more than one widget.

              So if u have multiple widgets, there is a better way than
              creating multiple plugins for each widget.
              But you should wait with that unless one plugin is ok to handle :)

              H 1 Reply Last reply 21 Jun 2018, 07:14
              1
              • M mrjj
                21 Jun 2018, 06:59

                @hjohn

                Hi
                All the functions showed must be implemented.
                Its not optional. All must be implemented.

                Its possible to have same plugin offer more than one widget.

                So if u have multiple widgets, there is a better way than
                creating multiple plugins for each widget.
                But you should wait with that unless one plugin is ok to handle :)

                H Offline
                H Offline
                hjohn
                wrote on 21 Jun 2018, 07:14 last edited by
                #7

                @mrjj yeah thanks..one last question:
                As i know if we work with Widget if have to call

                Widget w;
                w.show();
                

                in main.cpp.
                But here in this example from qtdocument
                http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html

                they are not including main.cpp file. Is this possible to run and display widget without main.cpp file

                M 1 Reply Last reply 21 Jun 2018, 07:27
                0
                • H hjohn
                  21 Jun 2018, 07:14

                  @mrjj yeah thanks..one last question:
                  As i know if we work with Widget if have to call

                  Widget w;
                  w.show();
                  

                  in main.cpp.
                  But here in this example from qtdocument
                  http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html

                  they are not including main.cpp file. Is this possible to run and display widget without main.cpp file

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 21 Jun 2018, 07:27 last edited by mrjj
                  #8

                  @hjohn
                  Hi
                  You can show a widget from anywhere.
                  But to prevent out of scope issues, you should new it

                  Widget* w = new Widget(this);
                  w->show();

                  But normally, a plugin for Designer DO NOT open other widgets.

                  H 1 Reply Last reply 21 Jun 2018, 07:53
                  0
                  • M mrjj
                    21 Jun 2018, 07:27

                    @hjohn
                    Hi
                    You can show a widget from anywhere.
                    But to prevent out of scope issues, you should new it

                    Widget* w = new Widget(this);
                    w->show();

                    But normally, a plugin for Designer DO NOT open other widgets.

                    H Offline
                    H Offline
                    hjohn
                    wrote on 21 Jun 2018, 07:53 last edited by hjohn
                    #9

                    @mrjj said in how the functions of QanalogClockPlugin has been called in qwidgetplugins.:

                    But normally, a plugin for Designer DO NOT open other widgets.

                    In example there is only one widget.which is analogclock and that i want to open. In example there is no any w.show();command

                    jsulmJ 1 Reply Last reply 21 Jun 2018, 07:59
                    0
                    • H hjohn
                      21 Jun 2018, 07:53

                      @mrjj said in how the functions of QanalogClockPlugin has been called in qwidgetplugins.:

                      But normally, a plugin for Designer DO NOT open other widgets.

                      In example there is only one widget.which is analogclock and that i want to open. In example there is no any w.show();command

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 21 Jun 2018, 07:59 last edited by
                      #10

                      @hjohn The application is showing the widget, the plug-in simply creates and returns an instance of it.

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

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hjohn
                        wrote on 21 Jun 2018, 09:29 last edited by hjohn
                        #11

                        When run Example of http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html
                        it generate
                        0_1529575055613_6b412866-740a-4bee-967c-13bf8d077d73-image.png

                        It means that This project is not created in the normal 'Qt-executable' kind format.Maybe because there is no main.cpp file.
                        what should i add or how to create project so that is get output as a analogClock .

                        jsulmJ 1 Reply Last reply 21 Jun 2018, 10:22
                        0
                        • H hjohn
                          21 Jun 2018, 09:29

                          When run Example of http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html
                          it generate
                          0_1529575055613_6b412866-740a-4bee-967c-13bf8d077d73-image.png

                          It means that This project is not created in the normal 'Qt-executable' kind format.Maybe because there is no main.cpp file.
                          what should i add or how to create project so that is get output as a analogClock .

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 21 Jun 2018, 10:22 last edited by
                          #12

                          @hjohn The main.cpp is part of QtDesigner.
                          So, it is a normal Qt application which loads plug-ins.
                          Again: a plug-in does NOT have a main.cpp, because it is a plug-in which is loaded by an application.
                          A plug-in is a library and a library does not have main.cpp.

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

                          H 1 Reply Last reply 21 Jun 2018, 11:19
                          1
                          • M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 21 Jun 2018, 11:15 last edited by
                            #13

                            Hi

                            To see the clock there is 2 options.

                            1:
                            Compile it as plugin and COPY the DLL to the Designer plugin folder in your Qt installation folder
                            ( or do make install )
                            Start Creator and then make project as normally with ui and
                            drag the analog clock to the new form.

                            2:
                            Dont use as plugin at all.
                            use the files analogclock.cpp/.h directly in a project
                            and simply NEW a analog clock and show it.

                            If you just started with Qt/programming. Designer plugins are maybe a bit
                            hard topic to start with :)

                            H 2 Replies Last reply 21 Jun 2018, 11:31
                            3
                            • jsulmJ jsulm
                              21 Jun 2018, 10:22

                              @hjohn The main.cpp is part of QtDesigner.
                              So, it is a normal Qt application which loads plug-ins.
                              Again: a plug-in does NOT have a main.cpp, because it is a plug-in which is loaded by an application.
                              A plug-in is a library and a library does not have main.cpp.

                              H Offline
                              H Offline
                              hjohn
                              wrote on 21 Jun 2018, 11:19 last edited by
                              #14

                              @jsulm so how am I supposed to load this plugin?
                              http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html

                              jsulmJ 1 Reply Last reply 21 Jun 2018, 11:28
                              1
                              • H hjohn
                                21 Jun 2018, 11:19

                                @jsulm so how am I supposed to load this plugin?
                                http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 21 Jun 2018, 11:28 last edited by
                                #15

                                @hjohn Please check what @mrjj said.
                                There is one important thing: if you want to use this plug-in in QtDesigner you have to use exactly same Qt version and same compiler as were used to build QtDesigner!

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

                                1 Reply Last reply
                                0
                                • M mrjj
                                  21 Jun 2018, 11:15

                                  Hi

                                  To see the clock there is 2 options.

                                  1:
                                  Compile it as plugin and COPY the DLL to the Designer plugin folder in your Qt installation folder
                                  ( or do make install )
                                  Start Creator and then make project as normally with ui and
                                  drag the analog clock to the new form.

                                  2:
                                  Dont use as plugin at all.
                                  use the files analogclock.cpp/.h directly in a project
                                  and simply NEW a analog clock and show it.

                                  If you just started with Qt/programming. Designer plugins are maybe a bit
                                  hard topic to start with :)

                                  H Offline
                                  H Offline
                                  hjohn
                                  wrote on 21 Jun 2018, 11:31 last edited by
                                  #16
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • M mrjj
                                    21 Jun 2018, 11:15

                                    Hi

                                    To see the clock there is 2 options.

                                    1:
                                    Compile it as plugin and COPY the DLL to the Designer plugin folder in your Qt installation folder
                                    ( or do make install )
                                    Start Creator and then make project as normally with ui and
                                    drag the analog clock to the new form.

                                    2:
                                    Dont use as plugin at all.
                                    use the files analogclock.cpp/.h directly in a project
                                    and simply NEW a analog clock and show it.

                                    If you just started with Qt/programming. Designer plugins are maybe a bit
                                    hard topic to start with :)

                                    H Offline
                                    H Offline
                                    hjohn
                                    wrote on 21 Jun 2018, 11:37 last edited by hjohn
                                    #17

                                    @mrjj said in how the functions of QanalogClockPlugin has been called in qwidgetplugins.:

                                    Start Creator and then make project as normally with ui and
                                    drag the analog clock to the new form.

                                    hey thanks.Can u elaborate this , It would be great help.

                                    M 1 Reply Last reply 21 Jun 2018, 13:01
                                    0
                                    • H hjohn
                                      21 Jun 2018, 11:37

                                      @mrjj said in how the functions of QanalogClockPlugin has been called in qwidgetplugins.:

                                      Start Creator and then make project as normally with ui and
                                      drag the analog clock to the new form.

                                      hey thanks.Can u elaborate this , It would be great help.

                                      M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 21 Jun 2018, 13:01 last edited by mrjj
                                      #18

                                      @hjohn
                                      Well if on windows.
                                      Check what your creator was compiled with.
                                      You need to use same compiler and ca. same Qt version.
                                      alt text
                                      Install visual studio 2015 or 2017 with 32 bit !
                                      This is a download from Microsoft site. Not Qt. ( not allowed)
                                      ( you cannot use mingw)
                                      Install the Qt for visual studio.
                                      (mingw version cannot be used)
                                      alt text

                                      THE ABOVE IS MUST DO! else it wont work.

                                      Then compile the plugin in RELEASE mode and 32 Bit. ( not 64)
                                      Go to its build folder and copy the DLL to
                                      alt text
                                      C:\Qt\Tools\QtCreator\bin\plugins\designer
                                      alt text

                                      Start Creator and go to design mode
                                      It will be in list to the left.
                                      Scroll down to find it.

                                      Note: this is considered intermediate level. :)

                                      H 1 Reply Last reply 23 Jun 2018, 10:27
                                      3
                                      • M mrjj
                                        21 Jun 2018, 13:01

                                        @hjohn
                                        Well if on windows.
                                        Check what your creator was compiled with.
                                        You need to use same compiler and ca. same Qt version.
                                        alt text
                                        Install visual studio 2015 or 2017 with 32 bit !
                                        This is a download from Microsoft site. Not Qt. ( not allowed)
                                        ( you cannot use mingw)
                                        Install the Qt for visual studio.
                                        (mingw version cannot be used)
                                        alt text

                                        THE ABOVE IS MUST DO! else it wont work.

                                        Then compile the plugin in RELEASE mode and 32 Bit. ( not 64)
                                        Go to its build folder and copy the DLL to
                                        alt text
                                        C:\Qt\Tools\QtCreator\bin\plugins\designer
                                        alt text

                                        Start Creator and go to design mode
                                        It will be in list to the left.
                                        Scroll down to find it.

                                        Note: this is considered intermediate level. :)

                                        H Offline
                                        H Offline
                                        hjohn
                                        wrote on 23 Jun 2018, 10:27 last edited by
                                        #19

                                        Thank you very much @mrjj
                                        Now I got the clear idea what was the mistake I was making. And thanks a lot for the efforts you did, it was a huge help.Thank you.

                                        1 Reply Last reply
                                        0

                                        1/19

                                        20 Jun 2018, 10:13

                                        • Login

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