Using Qt project code with earlier versions



  • Hi,

    I was using Qt 5.2.1 for creating a Windows C++ .pro project. The application worked well. Then, i download The last Qt version 5.12.3 and i create a Qt Widgets application. I used my Qt 5.2.1 version code (.cpp file code, .h Header code, and .ui file code). However, i get a build errors as if the 5.12.3 version do not recognize the classes used in the code, and which was used correctly in the Qt 5.2.1 version. Is there a way to fix this ?


  • Qt Champions 2018

    @ZINE

    Is there a way to fix this ?

    The best way is by giving us your exact error messages, because otherwise we'd need a cristal ball.

    Regards


  • Moderators

    @aha_1980 Well my crystal ball tells me the op did not link the (presumably) copied header, source and ui files inside the new *pro file. But just made an include "xyzzy.h"

    Prompting the error, as qmake failed to create the moc files for those classes.



  • @aha_1980 @J-Hilk Here is my .pro file in Qt 5.12.3 version :

    0_1556615852625_308a293b-94fa-46f8-83e3-0777a589048a-image.png
    0_1556615896391_c03b6a14-f0a6-4043-8863-2428d0510927-image.png

    Here is an example of errors from mainwindow.cpp :

    0_1556615655883_888fa518-ec73-4d02-a286-e06c9561f583-image.png

    And here is the include in the same mainwindow.cpp file :

    0_1556615730824_e30fb14c-e4f7-4763-9986-edb619f48b55-image.png

    The code work well in Qt 5.2.1 version. Can you give me some advice about how to change .pro file to fix this problem ?



  • you miss some header file - langue_button is not defined you should have something like

    private:
    QPushButton *langue_button;
    


  • @arsinte_andrei langue_button is already declared in mainwindow.h and ui_mainwindow.h ! these files are already included.


  • Moderators

    @ZINE

    Well my guess was not correct ;-)

    Did you forget to run qmake after adding those files to your pro file ?



  • @J-Hilk No. I copied the files to the project directory, i add the files to my pro file then i build the project. How i can run the qmake ?


  • Moderators


  • Qt Champions 2018

    @ZINE

    Please post code as text, not as screenshot! It's impossible for me to copy relavant lines and comment on them.

    That said, your .pro file looks overall sane, just the constructs at the beginning are redundand.

    QT = core gui widgets should be enough. Everything else until TARGET can be removed.

    The code errors come from the Clang Code Model, probably because it cannot find a header or has problems parsing a header. To investigate this problem, you should:

    1. Actually try to compile the project (Ctrl+B)
    2. Test if a new generated, simple project (form the wizards) works well.

    If you don't want to invest much time in this, Clang Code Model can be disabled in Help > About Plugins > Clang Code Model.

    Regards


Log in to reply
 

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