Results 1 to 8 of 8

Thread: CustomWidget plugin in Qt5.4 not working

  1. #1
    Join Date
    Apr 2015
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default CustomWidget plugin in Qt5.4 not working

    I have downloaded the Qt5.4 binaries for mingw and realizing that QtCreator is built using Visual studio, I downloaded the QtCreator sources and built it using the Qt5.4 mingw, so now I have a Qt Creator built using mingw. I tried the analog clock custom widget plugin example included with Qt5.4 examples, I built it and copied both the dll and lib.a into both folders for QtCreator built with mingw and the Qt5.4 plugins.
    The analog clock appears in the left hand side along with the standard widgets and I am able to drag it into the main form, The project build fine, but When I try to run it, I get the following error:

    QWidget: Must construct a QApplication before a QWidget
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.

    Any idea what possibly have I done wrong?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,327
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: CustomWidget plugin in Qt5.4 not working

    realizing that QtCreator is built using Visual studio
    It is totally, completely, absolutely irrelevant what language, compiler, or anything else that Qt Creator is built with. It could have been written in Martian and built using Martian Studio. Qt Creator is just another program. It is self-contained, and provides any Qt or other DLLs libraries it uses independently of the compiler you use. So you wasted your time rebuilding it.

    What matters is the kit that Qt Creator uses to build your project. In this case, if you installed a minGW Qt, and use minGW to build your projects, then you must ensure that the DLLs in the path are minGW-built DLLs, and that you are linking a release build with release DLLs only, and debug build with debug DLLs only.

    The error you are seeing is usually the result of incorrect DLL loading (i.e. wrong path) or more often a mixup of release and debug binaries. Check to make sure that if your plugin was built in release mode, you are loading it into a release mode exe. You cannot mix-and-match debug and release anywhere.

  3. The following user says thank you to d_stranz for this useful post:

    sueyllam (1st May 2015)

  4. #3
    Join Date
    Apr 2015
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: CustomWidget plugin in Qt5.4 not working

    Well thanks for the expert reply. I changed the build settings in QtCreator to release and it is running fine.
    However, for the benefit of other newbies, rebuilding qtcreator using qt5.4-mingw from sources was not waste of time. Everything is working fine under the new rebuilt qtcreator. However when I use the originally supplied qtcreator (built using Visual studio), after of course copying the dll and lib.a to the proper folders, the custom widgets do not even appear in qtcreator along with the standard widgets so it does not work. I read about this in stack-overflow about people having the same problem and it was explained that mingw and visual studio use different name mangling so they are not compatible...

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,327
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: CustomWidget plugin in Qt5.4 not working

    I read about this in stack-overflow about people having the same problem and it was explained that mingw and visual studio use different name mangling so they are not compatible...
    Yes, MSVC and minGW (as well as any other C++ compiler) will each have a different version of name mangling.

    The point you are missing is that you do not use the DLLs from Qt Creator's installation directory when building and linking your own Qt app. You use the DLLs from your Qt installation. Yes, you can build Qt Creator from source if you want to, but it has no relevance to using it to build your own Qt projects.

    If you are getting link or run-time errors, it is because your environment path or Qt kit configuration are loading and/or linking to the wrong DLLs. I use vanilla, straight out of the box Qt Creator to build Qt apps on Windows using Visual Studio 2008, Visual Studio 2013 and minGW 4.9.1, and I cross-compile for Android and linux using the same Qt Creator and cross-compilers. What you have to ensure is that when you configure the Qt Creator "kit" for whatever you are targeting, it is using the correct compiler, linker, make-specs and header files, and precompiled libraries / DLLS for that kit. The best way to ensure that is to either download a pre-built Qt distribution or build it from sources using the compiler and make-specs file for the target environment.

    I have independent Qt distributions for all of the compilers / targets I mentioned above, installed side-by-side on my development disk. I have only one copy of Qt Creator, and I use it for all of them.

  6. The following user says thank you to d_stranz for this useful post:

    sueyllam (1st May 2015)

  7. #5
    Join Date
    Apr 2015
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: CustomWidget plugin in Qt5.4 not working

    As much as what you say makes sense I cannot figure out what is wrong with my QtCreator built using MSVC, Here are snapshots showing its default kit and the fact that both custom widgets are not showing:
    QTCreatorMSVC.jpgQTCreatorMSVC-Kit.jpg

    Now for the QtCreator I built, it uses the same kit and both custom widgets are shown, the analog clock and the iconeditor:
    QTCreatorMingw.jpgQTCreatorMingw-Kit.jpg

    And I followed the same procedure by adding the dll and lib.a of both custom widgets to the proper folders of both Qt and The corresponding QtCreator.
    Could it be possibly has to do that the packaged QtCreator is on the C: drive with the Qt5.4, while the one I built is on the D: drive, where I built the custom widgets?


    Added after 23 minutes:


    Well clearly it does not make a difference where the custom widget libraries are built; just tried to build them on C:. Same disappointment...Cannot figure out any other reason!
    Last edited by sueyllam; 1st May 2015 at 19:12.

  8. #6
    Join Date
    Apr 2015
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: CustomWidget plugin in Qt5.4 not working

    Well after doing some search on the net, I found the following pdf document which explicitly states that you have to build qtcreator from the sources in order to be able to use plugins: Here is a snapshot...
    QtCreatorCompilation.jpg

    So I guess I had to build qtcreator anyway in order to add and create plugins. May be your point was that I did not have to use mingw I could have done it using MS Visual Studio and It would have run as well for plugins created with mingw Qt? was that your point?

  9. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,327
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: CustomWidget plugin in Qt5.4 not working

    So I guess I had to build qtcreator anyway in order to add and create plugins.
    Oh, it's my misunderstanding - I thought you were creating a plugin to use in your application. Yes, if you want to add a custom plugin to Qt Creator, the plugin does have to be built with the same compiler and version of Qt that your copy of Qt Creator uses. If you don't have that compiler, then yes, a rebuild of Qt Creator and the plugin with the same compiler and Qt version is required.

    Sorry, my mistake.

  10. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: CustomWidget plugin in Qt5.4 not working

    There are two different types of plugin:
    • Plugins you write to be used in your program at run time must be built with the same tool chain as your program and the Qt libraries it uses. This need not be related to the tool chain used to build Qt Creator.
    • Plugins used to make a custom widget accessible and usable in Qt Designer's tool box (standalone or embedded in Qt Creator). These plugins must be built with the same tool chain as the Qt Designer/Qt Creator And installed into the relevant location for those tools to locate and load.

  11. The following user says thank you to ChrisW67 for this useful post:

    sueyllam (2nd May 2015)

Similar Threads

  1. Qt Creator Replacing icons of tabs QTabWidget with labels on customwidget
    By qtnewbi3 in forum Qt Tools
    Replies: 1
    Last Post: 20th July 2011, 09:54
  2. Replies: 5
    Last Post: 7th May 2010, 13:54
  3. customwidget and event help
    By eva2002 in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2010, 06:37
  4. mysql plugin not working on qt 4.5.2
    By majer627 in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2009, 23:30
  5. Qwt plugin not working in Designer
    By Tiansen in forum Qwt
    Replies: 5
    Last Post: 9th March 2008, 16:43

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.