Although the local machine is installed with Gnome Ubuntu, you can also develop Qt programs. If you download and compile Qt4 normally, it will take a long time. Therefore, use apt-get to install Qt4. Run: $ sudoapt-getinstalllibqt4-devlibqt4-debuglibqt4-guilibqt4-sqlqt4-dev-toolsqt4-docqt4-designerqt4-qtconfi
Although the local machine is installed with Gnome Ubuntu, you can also develop Qt programs. If you download and compile Qt4 normally, it will take a long time. Therefore, use apt-get to install Qt4.
Run:
$ Sudo apt-get install libqt4-dev libqt4-debug libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer
The system automatically installs and sets the environment. This will be faster. If you compile the source code directly, it will take a very long time to install it.
Compile an example program:
# Include
# Include
Int main (int argc, char * argv [])
{
QApplication app (argc, argv );
QPushButton hello ("Hello, man! ");
Hello. resize (100, 30 );
Hello. show ();
Return app.exe c ();
}
Then run:
$ Qmake-project
$ Qmake
$ Make
$./Project Name
As follows:
Isp @ hitisp :~ /Qtsrc $ vim QtHello. cpp
Isp @ hitisp :~ /Qtsrc $ qmake-project
Isp @ hitisp :~ /Qtsrc $ qmake
Isp @ hitisp :~ /Qtsrc $ make
G ++-c-pipe-g-Wall-W-D_REENTRANT-DQT_GUI_LIB-DQT_CORE_LIB-I/usr/share/qt4/mkspecs/linux-g ++-I. -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
Isp @ hitisp :~ /Qtsrc $ ls
Makefile QtHello. cpp QtHello. o qtsrc. pro
Isp @ hitisp :~ /Qtsrc $./qtsrc
The running result is a small window with only one button titled project name.