Home > C, centOS, Fedora 12, Ubuntu, Unix/Linux > Centos c++ gui qt quick start

Centos c++ gui qt quick start

* Get Centos 5.4
* QT get it for c++: http://qt.nokia.com/downloads

1. Install the .bin

[root@www Desktop]# chmod a+x qt-sdk-linux-x86-opensource-2010.02.bin
[root@www Desktop]# ./qt-sdk-linux-x86-opensource-2010.02.bin


2. First project flow:

a. Project create
b. form build (dialog)
c. Form events/stored functions create named as ConversionForm.ui.h

#include <qvalidator.h>

void ConversionForm::accept(){

}

d. Main.cpp create

</pre>
#include <qapplication.h>
#include "conversionform.h"

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
ConversionForm w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();

}

* Follow the QT quick start mannual, very handy, maximium it will cost 5 minutes. (so, must work).

3. Run it


[root@www metric]# qmake -o Makefile metric.pro
[root@www metric]# make
/usr/lib/qt-3.3/bin/uic conversionform.ui -o .ui/conversionform.h
g++ -c -pipe -Wall -W -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables  -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
/usr/lib/qt-3.3/bin/uic conversionform.ui -i conversionform.h -o .ui/conversionform.cpp
g++ -c -pipe -Wall -W -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables  -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/conversionform.o .ui/conversionform.cpp
/usr/lib/qt-3.3/bin/moc .ui/conversionform.h -o .moc/moc_conversionform.cpp
g++ -c -pipe -Wall -W -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables  -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/moc_conversionform.o .moc/moc_conversionform.cpp
g++  -o metric .obj/main.o .obj/conversionform.o .obj/moc_conversionform.o   -L/usr/lib/qt-3.3/lib -lqt-mt -lXext -lX11 -lm
[root@www metric]# ls
conversionform.ui  conversionform.ui~  conversionform.ui.h  conversionform.ui.h~  main.cpp  Makefile  metric  metric.pro
[root@www metric]# metric
-bash: metric: command not found
[root@www metric]#
[root@www metric]# ./metric

Done.

Advertisements
Categories: C, centOS, Fedora 12, Ubuntu, Unix/Linux
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: