Also talk about the Qapplication:no of QT Classic error message such file or DIRECTORY__QT

Source: Internet
Author: User

This question seems to be a cliché, a lot of friends have also made a study on this issue, here I say my opinion, and for beginners, how to quickly locate problems, quickly solve problems,

Below is the complete elaboration of Netizen Zhu:

This error message is generally the novice in compiling QT4 first application "Hello,world", turn QT Programming the first example. They say it's simple.
#include <QApplication>
#include <QWidget>
int main (int argc, char *argv[])
{
Qapplication app (ARGC,ARGV);
Qwidget *ww=new qwidget ();
Ww->resize (300,200);
Ww->show ();
return App.exec ();
}
A compilation result appears above this error, it is called a depressed.

In fact, a little thought to follow the prompts, the novice is also able to solve their own problems. According to the prompt qapplication hint, should be the header file was not found. Then we can look at the environment variables in the current directory makefile Incpath know where make applications go to change files. For example
./makefile File Section content
Cxxflags =-pipe-o2-wall-w-d_reentrant $ (defines)
Incpath =-i/usr/share/qt4/mkspecs/linux-g++-I.-i/usr/include/qt4/qtcore-i/usr/include/qt4/qtgui-i/usr/includ E/qt4-i. I.-I.
LINK = g++
Line 16th inside, the corresponding to find/usr/include/qt4/qtgui/qapplication whether the file exists (generally does not exist, there will be no error). There are approximately two reasons why there is no qapplication file
1 does not install the QT4 development package.
The solution to the development package, such as Ubuntu, is to execute sudo install libqt4-dev;fedora/suse in the shell to execute sudo yum install in the shell Qt4-devel
2 Qt4 The development of the packaging, but called the Qt3 qmake
Because some system has installed the QT3, and installed the QT4. If you call the QT3 's qmake, then the header file path in the top Incpath also points to Qt3, so you can't find qapplication this file. The corresponding solution is to call the QT4 installation path qmake to generate makefile, preferably with full path. The Qmake installation path in my machine Qt4 is
zhu@ubuntu:~/test/widget$ dpkg-l qt4-qmake |grep qmake |grep Bin
/usr/bin/qmake-qt4
/usr/share/qt4/bin/qmake
So just execute
/usr/bin/qmake-qt4;make or/usr/share/qt4/bin/qmake:make.
Can compile this simplest QT4 application with Qt4 files.

Original link: http://www.cuteqt.com/blog/?p=307

For new learning Qt friends, in fact, as long as the understanding of these internal reasons can, this situation is generally the environment variables are not set the correct reason.

One is that the environment variables are not set at all, for example, using the SDK to install QT, but not using QT creator as the IDE (QT Creator will automatically set up the environment for developers at run time), but using other IDE or VIM, etc. for development, this will naturally burst this error.

The second is set the environment variable but not set correctly. For example, in the X11, after setting the environment variable, you need to log on to the shell, if you do not do so directly to start development, it is generally possible to report this error.

Third, there are multiple versions of QT in the system at the same time. For example, there are Qt3 and Qt4 coexisting, there are several different versions of QT4 exist, so you need to consider cleaning up the environment, using a "pure" QT4 environment; 1 is if on Windows, you can think about whether it is necessary to have so many versions at the same time, if there is no real need to unify, Of course, this is to create a "pure" QT4 environment; 2 is if it is on the X11, because the existence of QT3 may be the system needs, the system has a lot of packets are dependent on the QT3, then each of the different QT version of the switch between, change the setting of the environment variable, or set up for each QT version to be used by different users, each user has a unique environment, or the use of a script, the practice is to write for each QT version of the environment variable script, only when necessary to the current shell settings environment, this approach for beginners is a certain degree of difficulty, but the effect is relatively good.

Well, this question I would like to summarize the relatively clear, for your reference, if there are more cases, please add, we jointly find the best solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.