Use apt-get to install Qt4 in Ubuntu12.04. Run: 1. $ sudoapt-getinstalllibqt4-devlibqt4-debuglibqt4-guilibqt4-sqlqt4-dev-toolsqt4-docqt4-designerqt4-qtconfig the software packages listed above are required for the qt configuration environment, for example, the qt4-dev-tools contains Q
Install Qt4 using apt-get In Ubuntu 12.04.
Run:
$ Sudo apt-get install libqt4-dev libqt4-debug libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig
The software packages listed above are required for the qt configuration environment, for example, the qt4-dev-tools contains tools such as Qt Assistant and Qt Linguist, so they do not need to be installed separately. Others, qt4-doc is a help document that contains detailed descriptions of various class libraries in Qt and a wide range of example programs that can be opened using Qt Assistant tools. The qt4-qtconfig is a dialog box for configuring the Qt environment, which is usually the default and is rarely necessary to change. The qt4-demos contains many executable files and source code that can run. Qt4-designer is a designer used to design GUI Interfaces
Note:
$ Sudo apt-get install libqt4-debug when installing this software the system may prompt:
Reading the package list... complete
Analyzing the dependency tree of the software package
Reading status information... complete
There is no available package libqt4-debug now, but it is referenced by other packages.
This may mean that the missing software package may have been deprecated,
Or it can only be found in other release sources
However, the following software package replaces it:
Libqt4-dbg: i386 Co., libqt4-dbg.
So we use
$ Sudo apt-get install libqt4-dbg instead
After the installation is complete, let's try a program.
3. Write the source code first. Create the qt4hello folder, and then create the Qthello. cpp file. The content is as follows:
# Include # Include Int main (int argc, char * argv []) {QApplication app (argc, argv); QPushButton hello ("Hello Ubuntu! "); Hello. resize (100, 30); hello. show (); return app.exe c ();}
Enter $ gedit Qthello. cpp on the terminal (enter the above Program)
$ Qmake-project (generate Qt project)
$ Qmake (generate makefile file)
$ Make
G ++-c-pipe-g-Wall-W-D_REENTRANT-DQT_GUI_LIB-DQT_CORE_LIB-I/usr/share/qt4/mkspecs/linux-g ++-I appears. -I/usr/include/qt4/QtCore-I/usr/include/qt4/QtCore-I/usr/include/qt4/QtGui-I/usr/include/qt4/QtGui -I/usr/include/qt4-I. -I. -I. -o QtHello. o QtHello. cpp
G ++-o qtsrc QtHello. o-L/usr/lib-lQtGui-lQtCore-lpthread
Last $ ls
Makefile qt4hello qt4hello. pro Qthello. cpp Qthello. o
Then, $./qt4hello is displayed on the screen as a small window of hello. Now the installation is complete.
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2