When I learned QT from the new, Qt5.4 was re-installed, and when I ran the Hello World example, I encountered the following situation
<span style= "FONT-SIZE:18PX;" > #include <QApplication> #include <QDialog> #include <qlabel>int main (int argc, char *argv[]) { qapplication A (ARGC,ARGV); Qdialog W; Qlabel label (&W); Label.settext ("Hello world! I am QT "); W.show (); return a.exec ();} </span>
hint error not found:
#include<QApplication>
#include<qdialog>
#include<QLabel>
has been tangled up fast one day online can not find the answer, groping for a long time, the final discovery is the reason: Qt5 no longer use the Qtgui module, but use the Qtwidgets module.
So add in the. Pro fileGreaterThan (qt_major_version,4):QT+= Widgets
Solve the problem perfectly ....
By the way, summarize the related questions:
The following problems are encountered:
1. Since QT5 has moved most of the desktop parts to the QT widgets module, add the following line in. Pro
QT + = Widgets
2. The OWC10 used in the program, the use of ACTIVEQT, the original practice is in. Pro Plus config + = Qaxcontainer, now need to change to
QT + = Axcontainer
Of course, the original config + = Qaxcontainer will also be removed
3. To fully use the C++11 feature, add the following line to the. Pro
CONFIG + = c++11
4. In the source file, all involved in the original Qtgui in the visual parts, all to modify the header file reference, or add qtwidgets header file, such as:
#include <QtGui/QPushButton> change to #include <QPushButton> or #include <QtWidgets/QPushButton>
In places where you used # include <QtGui>, add #include <QtWidgets>
5. Since Qt5 removes the qtextcodec::setcodecforcstrings () function, there are two ways of modifying it in the case of directly writing Chinese characters in CPP:
A) If the previous source file encoding is GBK, you need to use the Qstring::fromlocal8bit () function to enclose the original kanji, or convert the source file encoding directly to UTF-8 (the disadvantage is that the MSVC compiler is not easy to use). I use the qstring::fromlocal8bit () to invoke the way (of course, another convenient function or macro to handle)
b) If the previous source file encoding is UTF-8, then nothing moves.
6. Previously used Qdesktopservices::storagelocation (QDESKTOPSERVICES::XXXX) to obtain some system directories, now you want to change to
Qstandardpaths::writablelocation (QSTANDARDPATHS::XXXX)
7. When Qfiledialog::getsavefilename () was previously called, if the file name is specified under Windows Using Native dialog, the file name will be displayed correctly, and now QT5 will not display correctly. So the latter two parameters are added, namely qfiledialog::getsavefilename (xxx, xxx, xxx, xxx, 0, Qfiledialog::D ontusenativedialog), so it is normal, It's just that the dialog box is not a system form.
8. Also, QT5 solves the problem with the Ui_qaxselect.h file. In the Qt4 era, when using ACTIVEQT, the old hint does not have this file, it is necessary to find the source code manual UIC Qaxselect.ui > ui_qaxselect.h to generate a bit, Qt5 the problem solved.
9. Use to print related classes, Qt5 separate into the Qtprintsupport module, so the header file # include <qtprintsupport>, in. Pro to add qt + = Printsupport
10. Using WebKit related visual parts such as Qwebpage, QT5 is placed in the Qtwebkitwidgets module alone, so add header file # include <qtwebkitwidgets> in. Pro Add qt + = Webkitwidgets
One. Qt4 in Cleanlooks, Plastique, CDE, motif and other theme styles No, the new fusion, okay, the problem is that my project framework uses the Cleanlooks theme style and then adds a custom style sheet, which is good, after the upgrade Qt5 , some of which are inconsistent or defective with windowsvista or fusion and have to be adjusted. Therefore, to the topic style relies on the more serious procedures, to measure whether to upgrade to QT5.
In the. Pro file, the target in QT4 (Qmake v2) is not filled in, then it automatically takes the. Pro file name, while in Qt5 (Qmake v3) This target has to be written.
Q_WS_XX macros are not available, use Q_OS_XX instead.
Qt5.4 encountered in finding the head file <QApplication> etc...