Install Qt4-[software and system]-general Linux technology-Linux programming and kernel information. For details, refer to the following section. Last spring, I wrote a small software program with Qt3. I feel that it is very convenient to use Qt as the interface program in Linux, which is similar to VC in Windows. therefore, when the ubuntu 7.10 system was installed last time, the Qt3 development kit was installed. By the way, how can I install the Qt3 software package? .
Now the Qt version has reached the Qt-4.3.2, recently intends to write a small program with Qt4. Install the following software package on the Internet:
The qt3-examples qt3-assistant here, because the corresponding qt4 version apt-get cannot be found, so the previous version is installed. below is a hello world of Qt4, which comes from the first program of C ++ GUI Programming with Qt 4, as follows:
# Include
# Include
Int main (int argc, char * argv [])
{
QApplication app (argc, argv );
QLabel * label = new QLabel ("Hello Qt! ");
Label-> show ();
Return app.exe c ();
}
We can see that the simple hello world and Qt3 have some changes.
Compile the program as follows:
# Qmake-project
Generate the configuration file xxx. pro (where xxx is the project file name)
# Qmake
Generate Makefile automatically
# Make
The following error message is displayed:
Me. cpp: 1: 28: Error: qt4/QApplication: No such file or directory
Me. cpp: 2: 22: Error: qt4/QLabel: No such file or directory
Me. cpp: In function 'int main (int, char **)':
Me. cpp: 5: Error: 'qapplication' not declared in this scope
Me. cpp: 5: Error: expected '; 'before' app'
Me. cpp: 6: Error: 'qlabel' has not been declared in this scope
Me. cpp: 6: Error: 'label' has not been declared in this scope
Me. cpp: 6: Error: expected type-specifier before 'qlabel'
Me. cpp: 6: Error: expected '; 'before' qlabel'
Me. cpp: 8: Error: 'app' has not been declared in this scope
Me. cpp: At global scope:
Me. cpp: 3: Warning: Unused parameter 'argc'
Me. cpp: 3: Warning: Unused parameter 'argv'
Make: *** [me. o] Error 1
Open the Makefile file and find that all the Qt files in it are related to Qt3. Use the qmake-v command to find that qmake version is 3, whereis find the directory where the qmake command is located/usr/bin/qmake
Now it's clear that qmake is a link that points to the qmake-qt3 via alternatives/qmake, and now you want to make qmake A qmake-qt4 by default, as long as you redirect the link
# Sudo rm/etc/alternatives/qmake
# Sudo ln-s/usr/bin/qmake-qt4/etc/alternatives/qmake
Similarly, if you want the designer command to use version 4 by default
# Sudo rm/etc/alternatives/designer
# Sudo ln-s/usr/bin/designer-qt4/etc/alternatives/designer
Now, qmake-project, qmake, and make all the above hello world files will go smoothly.
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.