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. Making a Qt custom widget without Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Making a Qt custom widget without Qt Creator

Scheduled Pinned Locked Moved Solved General and Desktop
40 Posts 4 Posters 13.9k 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.
  • P Offline
    P Offline
    Panoss
    wrote on last edited by Panoss
    #1

    I 'm trying to make a custom widget for Qt (and a plugin for the widget to be visible and active in Qt Designer) in c++.
    I 'm using NetBeans, not Qt Creator (because I have a slow pc, I think Qt Creator would be too 'heavy') and trying to follow this tutorial.
    My problem is I don't know:
    a. where to put these files
    b. how to compile the plugin

    I have Qt 4.8.6 framework at C:\Qt.
    Qt Designer at: C:\Qt\4.8.6\bin

    NetBean 's QMake command: C:\Qt\4.8.6\bin\qmake.exe

    (I see there is and a second qmake.exe at: C:\Qt\4.8.6\qmake)

    Edit: how silly of me, I just installed Qt Creator, it's not heavy at all nor too big!
    Looks very nice! I thought it's 1.2GB, while in fact it's only about 90MB!!!

    jsulmJ 1 Reply Last reply
    0
    • P Panoss

      I 'm trying to make a custom widget for Qt (and a plugin for the widget to be visible and active in Qt Designer) in c++.
      I 'm using NetBeans, not Qt Creator (because I have a slow pc, I think Qt Creator would be too 'heavy') and trying to follow this tutorial.
      My problem is I don't know:
      a. where to put these files
      b. how to compile the plugin

      I have Qt 4.8.6 framework at C:\Qt.
      Qt Designer at: C:\Qt\4.8.6\bin

      NetBean 's QMake command: C:\Qt\4.8.6\bin\qmake.exe

      (I see there is and a second qmake.exe at: C:\Qt\4.8.6\qmake)

      Edit: how silly of me, I just installed Qt Creator, it's not heavy at all nor too big!
      Looks very nice! I thought it's 1.2GB, while in fact it's only about 90MB!!!

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

      @Panoss You should take a look at http://doc.qt.io/qt-5/designer-creating-custom-widgets.html

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

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Panoss
        wrote on last edited by Panoss
        #3

        Ok, now that I've finished with Qt Creator 's installation (I hope :) ) I 'm trying to follow the tutorial you posted jsulm.
        But nowhere is mentioned:
        should I start a new Qt Application? Qt Console Application? or something else? in order to begin the tutorial.
        Maybe New Project->Library->Qt Creator Plugin?
        Or New Project->Other->Qt Custom Designer Widget?

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Panoss
          wrote on last edited by Panoss
          #4

          From what I understand, I must build the plugin with qmake? Or something like this?
          I 'm lost....

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

            Hi,

            If I may, upgrade your Qt version to Qt 5. Qt 4 has reached EOL so unless you have a very good reason to, don't start new project with it.

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

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Panoss
              wrote on last edited by Panoss
              #6

              Yes I have upgraded to 5 already.
              And I m using Qt Creator, not NetBeans.
              But still haven't managed to make any progress in widget creation...despite the tutorials I m reading...

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

                You should have a look at "Qt Custom Designer Widget".

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

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Panoss
                  wrote on last edited by Panoss
                  #8

                  Thanks I 've looked at these a few hundrend times, didn't help.
                  Looking here and ther,e I conclude that I must compile (with qmake??) the plugin (which serves as a wpapper for the widget), and put it in a folder /desigenr/plugins...

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Panoss
                    wrote on last edited by Panoss
                    #9

                    I think I 'm close.
                    My files are at:
                    C:\Documents\QtProjects\mycustomwidget:
                    --customwidgetplugin.pro
                    --analogclock.h
                    --analogclock.cpp
                    --customwidgetplugin.h
                    --customwidgetplugin.cpp

                    I open a console:
                    cd C:\Documents\QtProjects\mycustomwidget
                    qmake

                    And so a file named MakeFile is created. It has, at the top: Command: C:\Qt\5.8\mingw53_32\bin\qmake.exe -o Makefile customwidgetplugin.pro
                    I give this command in console, seems like it's doing something, and shows the message: Info: creating stash file C:\Documents\QtProjects\mycustomwidget.qmake.stash

                    I open Qt Designer and no new widget is added in it...:(

                    Isn't the procedure I follow the correct one?

                    mrjjM jsulmJ 2 Replies Last reply
                    1
                    • P Panoss

                      I think I 'm close.
                      My files are at:
                      C:\Documents\QtProjects\mycustomwidget:
                      --customwidgetplugin.pro
                      --analogclock.h
                      --analogclock.cpp
                      --customwidgetplugin.h
                      --customwidgetplugin.cpp

                      I open a console:
                      cd C:\Documents\QtProjects\mycustomwidget
                      qmake

                      And so a file named MakeFile is created. It has, at the top: Command: C:\Qt\5.8\mingw53_32\bin\qmake.exe -o Makefile customwidgetplugin.pro
                      I give this command in console, seems like it's doing something, and shows the message: Info: creating stash file C:\Documents\QtProjects\mycustomwidget.qmake.stash

                      I open Qt Designer and no new widget is added in it...:(

                      Isn't the procedure I follow the correct one?

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

                      @Panoss

                      Hi
                      just a note
                      Unless you compile your own Creator with mingw then
                      its not possible to make Designer plugins with
                      mingw.
                      It has to be vs 2013/ 2015 ( for 5.8)
                      Since Creator is build with that compiler and the plugin is an DLL.

                      So it sounds good but unless you use visual studio or your own mingw Creator it
                      wont work.

                      alt text

                      P 1 Reply Last reply
                      2
                      • P Panoss

                        I think I 'm close.
                        My files are at:
                        C:\Documents\QtProjects\mycustomwidget:
                        --customwidgetplugin.pro
                        --analogclock.h
                        --analogclock.cpp
                        --customwidgetplugin.h
                        --customwidgetplugin.cpp

                        I open a console:
                        cd C:\Documents\QtProjects\mycustomwidget
                        qmake

                        And so a file named MakeFile is created. It has, at the top: Command: C:\Qt\5.8\mingw53_32\bin\qmake.exe -o Makefile customwidgetplugin.pro
                        I give this command in console, seems like it's doing something, and shows the message: Info: creating stash file C:\Documents\QtProjects\mycustomwidget.qmake.stash

                        I open Qt Designer and no new widget is added in it...:(

                        Isn't the procedure I follow the correct one?

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

                        @Panoss To add to @mrjj : it is not enough to execute qmake - qmake is not a compiler, it does not compile your code it just generates Makefiles. After qmake you need to execute make (nmake.exe in case Visual Studio is used) and then make install.

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

                        1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @Panoss

                          Hi
                          just a note
                          Unless you compile your own Creator with mingw then
                          its not possible to make Designer plugins with
                          mingw.
                          It has to be vs 2013/ 2015 ( for 5.8)
                          Since Creator is build with that compiler and the plugin is an DLL.

                          So it sounds good but unless you use visual studio or your own mingw Creator it
                          wont work.

                          alt text

                          P Offline
                          P Offline
                          Panoss
                          wrote on last edited by Panoss
                          #12

                          @mrjj said in Making a Qt custom widget without Qt Creator:

                          @Panoss

                          Hi
                          just a note
                          Unless you compile your own Creator with mingw then
                          its not possible to make Designer plugins with
                          mingw.
                          It has to be vs 2013/ 2015 ( for 5.8)
                          Since Creator is build with that compiler and the plugin is an DLL.

                          So it sounds good but unless you use visual studio or your own mingw Creator it

                          Wow!! this was quite a shock form me! :)
                          I 'd rather not to compile it with my MingW, I think this is a very loooong process..

                          So you 're saying I should Uninstall Qt Creator + Qt, and install a version:
                          a. either With Visual Studio
                          b. or a different mingW Creator version?

                          If so, I choose the second. But, which MingW + Qt Creator file should I download? (I don't care if it's gonna be Qt 5.8 or any other)

                          jsulmJ 1 Reply Last reply
                          0
                          • P Panoss

                            @mrjj said in Making a Qt custom widget without Qt Creator:

                            @Panoss

                            Hi
                            just a note
                            Unless you compile your own Creator with mingw then
                            its not possible to make Designer plugins with
                            mingw.
                            It has to be vs 2013/ 2015 ( for 5.8)
                            Since Creator is build with that compiler and the plugin is an DLL.

                            So it sounds good but unless you use visual studio or your own mingw Creator it

                            Wow!! this was quite a shock form me! :)
                            I 'd rather not to compile it with my MingW, I think this is a very loooong process..

                            So you 're saying I should Uninstall Qt Creator + Qt, and install a version:
                            a. either With Visual Studio
                            b. or a different mingW Creator version?

                            If so, I choose the second. But, which MingW + Qt Creator file should I download? (I don't care if it's gonna be Qt 5.8 or any other)

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

                            @Panoss No. No need to uninstall QtCreator (why should you)? Install Qt for VC2015 and VC2015 (you can get it for free).
                            The thing is: you cannot mix different compilers (because of C++, not Qt fault). Since QtCreator is built using VC2015 you have to use VC2015 to write plug-ins for it.
                            Official QtCretor is built using VC2015, you cannot use MinGW to write plug-ins for it. As far as I know there is no official QtCreator build made with MinGW.

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

                            P 1 Reply Last reply
                            2
                            • jsulmJ jsulm

                              @Panoss No. No need to uninstall QtCreator (why should you)? Install Qt for VC2015 and VC2015 (you can get it for free).
                              The thing is: you cannot mix different compilers (because of C++, not Qt fault). Since QtCreator is built using VC2015 you have to use VC2015 to write plug-ins for it.
                              Official QtCretor is built using VC2015, you cannot use MinGW to write plug-ins for it. As far as I know there is no official QtCreator build made with MinGW.

                              P Offline
                              P Offline
                              Panoss
                              wrote on last edited by
                              #14

                              @jsulm said in Making a Qt custom widget without Qt Creator:

                              Install Qt for VC2015 and VC2015 (you can get it for free).

                              I'll have to uninstall my curent Qt, right? (through on-line installer I mean)

                              jsulmJ 1 Reply Last reply
                              0
                              • P Panoss

                                @jsulm said in Making a Qt custom widget without Qt Creator:

                                Install Qt for VC2015 and VC2015 (you can get it for free).

                                I'll have to uninstall my curent Qt, right? (through on-line installer I mean)

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

                                @Panoss No need to uninstall your current Qt - you can have as many Qt installations as you like.
                                Use Qt Maintenance Tool to add Qt for VC2015.

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

                                P 1 Reply Last reply
                                1
                                • jsulmJ jsulm

                                  @Panoss No need to uninstall your current Qt - you can have as many Qt installations as you like.
                                  Use Qt Maintenance Tool to add Qt for VC2015.

                                  P Offline
                                  P Offline
                                  Panoss
                                  wrote on last edited by
                                  #16

                                  In Qt Maintenance Tool I have these options under Qt 5.8:
                                  WinRt arm7(MSVC2015)
                                  WinRt x64 (MSVC2015)
                                  WinRt x86 (MSVC2015)
                                  Windows Phone arm (MSVC2013)
                                  Windows Phone x86(MSVC2013)
                                  Windows Runtime 8.1 x64 (MSVC2013)
                                  msvc2013 32-bit
                                  msvc2015 32-bit

                                  I suppose I 'll have to choose the 'msvc2015 32-bit', right?

                                  mrjjM 1 Reply Last reply
                                  0
                                  • P Panoss

                                    In Qt Maintenance Tool I have these options under Qt 5.8:
                                    WinRt arm7(MSVC2015)
                                    WinRt x64 (MSVC2015)
                                    WinRt x86 (MSVC2015)
                                    Windows Phone arm (MSVC2013)
                                    Windows Phone x86(MSVC2013)
                                    Windows Runtime 8.1 x64 (MSVC2013)
                                    msvc2013 32-bit
                                    msvc2015 32-bit

                                    I suppose I 'll have to choose the 'msvc2015 32-bit', right?

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

                                    @Panoss
                                    yes. as long as it matches the visual studio suite you install later it should be fine.

                                    Can I ask what goal is ?
                                    You want to create a custom Designer plugin and use in your windows project or
                                    what is the plan?
                                    Or is just to test it out?

                                    Yes compiling Creator do take some time.
                                    I didnt use the make install thing.
                                    I simply copied worldtimeclockplugin.dll to
                                    M:\1_Creator\qt-creator-build-2\bin\plugins\designer
                                    (bin\plugins\designer)
                                    and it was visible in designer.

                                    So if goal is to produce a real plugin for Designer, then you need visual studio.

                                    If just for trying it out, we could cheat and i can give u the mingw Creator.
                                    Its like 50 MB download.
                                    But for a real project/plugin, the Visual Studio road is better.

                                    P 1 Reply Last reply
                                    0
                                    • mrjjM mrjj

                                      @Panoss
                                      yes. as long as it matches the visual studio suite you install later it should be fine.

                                      Can I ask what goal is ?
                                      You want to create a custom Designer plugin and use in your windows project or
                                      what is the plan?
                                      Or is just to test it out?

                                      Yes compiling Creator do take some time.
                                      I didnt use the make install thing.
                                      I simply copied worldtimeclockplugin.dll to
                                      M:\1_Creator\qt-creator-build-2\bin\plugins\designer
                                      (bin\plugins\designer)
                                      and it was visible in designer.

                                      So if goal is to produce a real plugin for Designer, then you need visual studio.

                                      If just for trying it out, we could cheat and i can give u the mingw Creator.
                                      Its like 50 MB download.
                                      But for a real project/plugin, the Visual Studio road is better.

                                      P Offline
                                      P Offline
                                      Panoss
                                      wrote on last edited by Panoss
                                      #18

                                      My goal is to create a real widget (ok plugin which wraps the widget).
                                      The strange thing is that I managed to create Qt widgets with Python, SO MUCH easier, just two files, one the plugin and one the widget, put in the right place and immediatelly show up in Qt Designer!!!
                                      I can't believe that with Qt Creator it's so much harder!!!
                                      Antway...I 'm thinking of using Visual Studio Express 2015.
                                      Is this suitable as Visual Studio?

                                      mrjjM jsulmJ 2 Replies Last reply
                                      0
                                      • P Panoss

                                        My goal is to create a real widget (ok plugin which wraps the widget).
                                        The strange thing is that I managed to create Qt widgets with Python, SO MUCH easier, just two files, one the plugin and one the widget, put in the right place and immediatelly show up in Qt Designer!!!
                                        I can't believe that with Qt Creator it's so much harder!!!
                                        Antway...I 'm thinking of using Visual Studio Express 2015.
                                        Is this suitable as Visual Studio?

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

                                        @Panoss
                                        Im not sure express will work but it might nowadays.
                                        I only heard of
                                        https://www.visualstudio.com/vs/community/
                                        But i can be wrong. I dont use visual studio at all. :)

                                        The reason for it being hard in C++ than python is the way DLLS works in windows.
                                        ( and python is not compiled)
                                        On linux its more easy as there is only gcc compiler.

                                        Just final question.
                                        It is easy to use custom plugins without all the plugin code using
                                        promotion.
                                        http://doc.qt.io/qt-5/designer-using-custom-widgets.html

                                        That however do not provide Design time editing of its properties.

                                        P 1 Reply Last reply
                                        0
                                        • P Panoss

                                          My goal is to create a real widget (ok plugin which wraps the widget).
                                          The strange thing is that I managed to create Qt widgets with Python, SO MUCH easier, just two files, one the plugin and one the widget, put in the right place and immediatelly show up in Qt Designer!!!
                                          I can't believe that with Qt Creator it's so much harder!!!
                                          Antway...I 'm thinking of using Visual Studio Express 2015.
                                          Is this suitable as Visual Studio?

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

                                          @Panoss Use Community edition, it is free. Don't forget to select C++ during installation.

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

                                          1 Reply Last reply
                                          1

                                          • Login

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