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 rich examples Program , You can use the QT assistant tool to open the reading. 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 that can run and Source code . 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. First write the source Code . Create the qt4hello folder, and then create the qthello. cpp file. The content is as follows:
# Include <qapplication> # include <qpushbutton> 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.
This articleArticleFrom the Linux community website (www.linuxidc.com) Original article: http://www.linuxidc.com/Linux/2012-05/60770.htm