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 ?
-
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 ?
-
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
@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 :
Here is an example of errors from mainwindow.cpp :
And here is the include in the same mainwindow.cpp file :
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.
-
@aha_1980 @J-Hilk Here is my .pro file in Qt 5.12.3 version :
Here is an example of errors from mainwindow.cpp :
And here is the include in the same mainwindow.cpp file :
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 ?
-
@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 ?
-
@aha_1980 @J-Hilk Here is my .pro file in Qt 5.12.3 version :
Here is an example of errors from mainwindow.cpp :
And here is the include in the same mainwindow.cpp file :
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 ?
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 untilTARGET
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:
- Actually try to compile the project (Ctrl+B)
- 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