Results 1 to 20 of 32

Thread: Properly adding custom widget into Qt Designer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    3

    Default Properly adding custom widget into Qt Designer

    Hello,

    I'm new to Qt, and I've been experimenting with a few things. I'm stuck with adding custom widgets to Qt Designer. I used the example given in Qt 5.3 (D:\Qt\Qt5.3.0\Examples\Qt-5.3\designer\customwidgetplugin), and ran it with release mode. Qt showed the 'find custom executable' dialogbox, which I think is fine (it's plugin anyway). Now, there are a few lines of command like:

    Qt Code:
    1. TARGET = $$qtLibraryTarget($$TARGET)
    2.  
    3. target.path = $$[QT_INSTALL_PLUGINS]/designer
    4. INSTALLS += target
    To copy to clipboard, switch view to plain text mode 

    I can't find the DLL installed in any 'designer' folder on my installation directory. The custom widget doesn't show up on the left side on Designer either, or pops up when I try to promote a blank widget. When I tried to put the resulting DLL into D:\Qt\Qt5.3.0\Tools\QtCreator\bin\plugins\designer , the designer plugins dialogbox shows that the plugin failed because it used an incompatible library ([5.3.0] release).

    Is there anything that I missed?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Properly adding custom widget into Qt Designer

    You need to build the plugin with the same compiler, Qt version and same mode (release) Creator was built with. This might not be the same version you are using for building your programs.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    3

    Default Re: Properly adding custom widget into Qt Designer

    Quote Originally Posted by wysota View Post
    You need to build the plugin with the same compiler, Qt version and same mode (release) Creator was built with. This might not be the same version you are using for building your programs.
    Yes, I have tried to check with this answer. The problem is, I have never installed another version of Qt before on my machine. Another computer (also installed with Qt 5.3.0 and definitely compiled with mingw) also has the same problem. I used the same source code without any alteration, ran qmake, ran it with release mode, and when I put the resulting .a and .dll files into the plugins/designer folder the same error popped out. The custom widget won't appear on QtCreator-integrated Designer or non-integrated Designer.
    On the past documentations, I found a command - Q_EXPORT_PLUGIN2(), which is not in the customwidgetplugin source code example in 5.3. Is this actually required in this version?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Properly adding custom widget into Qt Designer

    As I said you need to build the plugin so that it is binary compatible with your Qt Creator which has its own Qt binaries. You can check the version from Creator's help menu.

    Alternatively you can build Creator yourself from sources with the version of Qt you are using for your programs and then you will be able to use the plugin built with the same toolchain.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    3

    Default Re: Properly adding custom widget into Qt Designer

    Quote Originally Posted by wysota View Post
    As I said you need to build the plugin so that it is binary compatible with your Qt Creator which has its own Qt binaries. You can check the version from Creator's help menu.

    Alternatively you can build Creator yourself from sources with the version of Qt you are using for your programs and then you will be able to use the plugin built with the same toolchain.
    The about window says "Qt Creator 3.1.1, based on Qt 5.2.1 (MSVC 2010) 32 bit". So I have to either compile the plugin again to Qt 5.2.1 & MSVC 2010, or compile my own Creator with that version?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Properly adding custom widget into Qt Designer

    Basically yes. It doesn't have to be Qt 5.2.1, it can be any of Qt 5.2.x, but it does have to be 32bit MSVC2010. If you decide to build Qt Creator yourself, you are free to choose any compiler and any supported Qt version.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    Baltharos (20th January 2015)

  8. #7
    Join Date
    Jan 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    3

    Default Re: Properly adding custom widget into Qt Designer

    Quote Originally Posted by wysota View Post
    Basically yes. It doesn't have to be Qt 5.2.1, it can be any of Qt 5.2.x, but it does have to be 32bit MSVC2010. If you decide to build Qt Creator yourself, you are free to choose any compiler and any supported Qt version.
    Okay, thanks a lot! Also a question again (I'm sorry): I assume that to embed my own widgets/plugins to QtCreator/Designer I have to refer to the Creator build version, but if I want to add custom libraries/plugins to my applications using Qt 5.3 compiled with mingw, I have to build them with version 5.3 + mingw right?

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Properly adding custom widget into Qt Designer

    Quote Originally Posted by Baltharos View Post
    but if I want to add custom libraries/plugins to my applications using Qt 5.3 compiled with mingw, I have to build them with version 5.3 + mingw right?
    Yes, that's correct. Just bear in mind that if you split your plugin into two parts -- a library implementing the widget and a plugin itself that uses this library (be it statically or dynamically linked), you can link your application againt that library only.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Jan 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    3

    Default Re: Properly adding custom widget into Qt Designer

    Quote Originally Posted by wysota View Post
    Yes, that's correct. Just bear in mind that if you split your plugin into two parts -- a library implementing the widget and a plugin itself that uses this library (be it statically or dynamically linked), you can link your application againt that library only.
    Okay, thanks a lot! It works now, although I have to use version 5.2.1 and version 5.3.0 together. Is it possible to use 5.3.2-compiled library/plugins in 5.3.0-compiled applications? I'm gonna try to shift to online installer (so I can use a single Creator), and the one offered is 5.3.2..
    Last edited by Baltharos; 21st January 2015 at 07:39.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Properly adding custom widget into Qt Designer

    Quote Originally Posted by Baltharos View Post
    Is it possible to use 5.3.2-compiled library/plugins in 5.3.0-compiled applications?
    It should be ok.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    Jan 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    3

    Default Re: Properly adding custom widget into Qt Designer

    Quote Originally Posted by wysota View Post
    It should be ok.
    Thanks a lot!

Similar Threads

  1. Replies: 7
    Last Post: 18th August 2011, 14:43
  2. Replies: 1
    Last Post: 23rd June 2011, 23:09
  3. Custom widget won't size properly in a table cell
    By zeroknowledge in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2011, 16:32
  4. Adding Custom Widgets to the QT Designer
    By Polnareff in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2010, 21:31
  5. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 13:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.