[SOLVED] Qt 4.8 library project with QWidget?



  • Hello,

    I was given some C++ code from another team and have to write a tutorial from it.
    They start with a C++ library project that contains Qt plugins implementations. I have troubles getting the following include to work:

    @#include <QWidgets>@

    I use MSVC 2010, Qt Creator 5.2.0, Qt 4.8.5. A Qt console app works.

    In my .pro file, adding the folllowing doesn't help resolving the include:

    @QT += widgets@

    or

    @QT += gui@

    or both.

    I've tested the following: create a library project and checking "QtWidgets" when asked which modules to include.

    Then it adds to .pro file "QT += widgets" as first try above.

    I strongly guess Qt Creator based itself on Qt5 modules names, since they're different in Qt 4.8 and 5. Because I've read here and there this code:

    @greaterThan(QT_MAJOR_VERSION, 4): QT += widgets@

    Thanks for pointers.

    Edited: I'd like to avoid:
    @#include <QtGui>@ as stated here: http://qt-project.org/doc/qt-4.8/mainwindows-dockwidgets.html
    because I undestood it means loading a lot of maybe unneeded libs.



  • OK this thread helped me: http://qt-project.org/forums/viewthread/26070

    So it's working with:

    @QT += core gui@

    @#include <QWidget>@ without final "s"!!

    while for Qt5 you have to
    @QT += core gui widgets@

    @#include <QtWidgets>@ with additional "t" and "s"!

    Why did they change so many things that newbies easily get confused? ^^


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.