Results 1 to 8 of 8

Thread: CustomWidget plugin in Qt5.4 not working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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)

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.