ºìÁªLinuxÃÅ»§
Linux°ïÖú

ǶÈëʽ¹¤¾ßQtµÄ°²×°ÓëʹÓÃ

·¢²¼Ê±¼ä:2006-08-20 16:14:32À´Ô´:ºìÁª×÷Õß:smallwl
¡¡¡¡QtÊÇTrolltech¹«Ë¾µÄÒ»¸ö²úÆ·¡£TrolltechÊÇŲÍþµÄÒ»¼ÒÈí¼þ¹«Ë¾£¬Ö÷Òª¿ª·¢Á½ÖÖ²úÆ·£ºÒ»ÖÖÊÇ¿çƽ̨ӦÓóÌÐò½çÃæ¿ò¼Ü£»ÁíÍâÒ»ÖÖ¾ÍÊÇÌṩ¸ø×öǶÈëʽLinux¿ª·¢µÄÓ¦ÓóÌÐòƽ̨£¬Äܹ»Ó¦Óõ½PDAºÍ¸÷ÖÖÒƶ¯É豸ÉÏ¡£QtºÍQtopia·Ö±ðÊÇÆäÖоßÓдú±íÐÔµÄÁ½¸ö¡£

¡¡¡¡QtÊÇÒ»¸ö¶àƽ̨µÄC++ͼÐÎÓû§½çÃæÓ¦ÓóÌÐò¿ò¼Ü£¬ËüÄܸøÓû§Ìṩ¾«ÃÀµÄͼÐÎÓû§½çÃæËùÐèÒªµÄËùÓÐÔªËØ£¬¶øÇÒËüÊÇ»ùÓÚÒ»ÖÖÃæÏò¶ÔÏóµÄ˼Ï룬ËùÒÔÓû§¶ÔÆä¶ÔÏóµÄÀ©Õ¹ÊÇÏ൱ÈÝÒ׵ģ¬²¢ÇÒËü»¹Ö§³ÖÕæÕýµÄ×é¼þ±à³Ì¡£

¡¡¡¡QtÊÇLinux×ÀÃæ»·¾³KDEµÄ»ù´¡¡£±ÊÕßÈÏΪ£¬¿ÉÒÔ˵QtÓëWindowsϵÄMfcµÄʵÖÊÊÇÒ»ÑùµÄ£¬ËùÒÔQt×î´óµÄÓŵãÔÚÓÚÆä¿çƽ̨ÐÔ£¬¿ÉÒÔÖ§³ÖÏÖÓеĶàÖÖ²Ù×÷ϵͳƽ̨£¬Ö÷ÒªÓУº

¡ô MS/Windows 95¡¢Windows 98¡¢WindowsNT 4.0¡¢Windows 2000¡¢Windows XP£»

¡ô Unix/X11 Linux¡¢Sun Solaris¡¢HP-UX¡¢Compaq True64Unix¡¢IBM AIX¡¢SGI IRIXºÍºÜ¶àÆäËüX11ƽ̨£»

¡ô Macintoshi Mac OSX£»

¡ô Embedded--´øFramBufferµÄLinuxƽ̨¡£

ÏÂÃæ¼òµ¥½éÉÜÒ»ÏÂQt/EmbeddedºÍQtopiaÔÚLinuxÉϵݲװºÍʹÓ㬻¹ÓÐÔÚ¿ª·¢¹ý³ÌÖпÉÄÜÅöµ½µÄһЩÎÊÌâ¡£

Qt ºÍQtopiaµÄ°²×°

Èç¹ûÐèÒª°²×°Ò»¸ö´øFramBufferµÄQtopiaƽ̨£¬ÐèÒªÓÐÒÔÏÂÈí¼þ£¨ËùÁоÙÈí¼þÒÔ±ÊÕßʹÓõÄΪÀý£©£º

¡ô Qtopia 1.6.0£»

¡ô Tmake 1.11£»

¡ô Qt/Embedded 2.3.4£¨Qtopia 1.6.0ÊÇ»ùÓڸÿª·¢Æ½Ì¨ÉÏ¿ª·¢µÄ£©£»

¡ô Qt/Embedded 2.3.2 for X11£»

¡ô Qt 3.1.2 for X11¡£

ÔÚTrolltech¹«Ë¾µÄÍøÕ¾ÉÏ¿ÉÒÔÏÂÔظù«Ë¾ËùÌṩµÄQt/EmbeddedµÄÃâ·Ñ°æ±¾¡£

Qtopiaƽ̨°²×°·ÖΪÒÔϼ¸¸ö²½Ö裺

1. ½â°üQtopia

ÔÚLinuxÃüÁîģʽÏÂÔËÐÐÒÔÏÂÃüÁ

tar xfz qtopia-source-1.6.0 £¨½â°ü£©
cd qtopia-source-1.6.0
export QPEDIR=$PWD £¨ÉèÖû·¾³±äÁ¿£©
cd..



2. °²×°Tmake

ÔÚLinuxÃüÁîģʽÏÂÔËÐÐÒÔÏÂÃüÁ

tar xfz tmake-1.11.tar.gz
export TMAKEDIR=$PWD/tmake-1.11
export TMAKEPATH=$TMAKEDIR/lib/qws/linux-x86-g++
export PATH=$TMAKEDIR/bin:$PATH




3. °²×°Qt/Embedded2.3.4

ÔÚLinuxÃüÁîģʽÏÂÔËÐÐÒÔÏÂÃüÁ


tar xfz qt-embedded-2.3.4-commercial.tar.gz
cd qt-2.3.4
export QTDIR=$PWD
export QTEDIR=$QTDIR
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
cp $QPEDIR/src/qt/qconfig-qpe.h src/tools/
. /configure -qconfig qpe -qvfb -depths 4,8,16,32
make sub-src
cd ..




Ò²¿ÉÒÔÔÚconfigureµÄ²ÎÊýÖÐÌí¼Ó£­system£­jpegºÍgif£¬Ê¹Qtopiaƽ̨ÄÜÖ§³Öjpeg¡¢gif¸ñʽµÄͼÐΡ£

4. °²×°Qt/X11 2.3.2

ÔÚLinuxÃüÁîģʽÏÂÔËÐÐÒÔÏÂÃüÁ


tar xfz qt-x11-2.3.2-commercial.tar.gz
cd qt-2.3.2
export QTDIR=$PWD
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
. /configure -no-opengl
make
make -C tools/qvfb
mv tools/qvfb/qvfb bin
cp bin/uic $QTEDIR/bin
cd ..




¸ù¾Ý¿ª·¢Õß±¾ÉíµÄ¿ª·¢»·¾³£¬Ò²¿ÉÒÔÔÚconfigureµÄ²ÎÊýÖÐÌí¼Ó±ðµÄ²ÎÊý£¬±ÈÈç-no-opengl»ò-no-xfs£¬¿ÉÒÔ¼üÈë./configure -helpÀ´»ñµÃһЩ°ïÖúÐÅÏ¢¡£

5. °²×°Qt/X11 3.1.2

ÔÚLinuxÃüÁîģʽÏÂÔËÐÐÒÔÏÂÃüÁ


tar xfz qt-x11-commercial-3.1.x.tar.gz
cd qt-x11-commercial-3.1.x
export QTDIR=$PWD
export QT3DIR=$QTDIR
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
./configure -thread
make
cd ..




6. °²×°Qtopia

ÔÚLinuxÃüÁîģʽÏÂÔËÐÐÒÔÏÂÃüÁ


cd qtopia-source-1.6.x
export QTDIR=$QTEDIR
export QPEDIR=$PWD
export PATH=$QPEDIR/bin:$PATH
cd src
./configure
make
cd ../..




7. °²×°Qtopia×ÀÃæ


cd qtopia-source-1.6.x/src
export QTDIR=$QT3DIR
./configure -qtopiadesktop
make
mv qtopiadesktop/bin/qtopiadesktop ../bin
cd ..





QtºÍQt DesignerµÄʹÓÃ

¸ù¾ÝÉÏÃæµÄ²½Öè°²×°Íê³ÉÁËQt/EmbeddedºÍQtopiaÖ®ºó£¬¾Í¿ÉÒÔÔËÐÐÕâЩ³ÌÐòÁË¡£

ÔËÐÐQtµÄÐéÄâ·ÂÕæ´°¿Ú£ºÔÚLinuxµÄͼÐÎģʽÏÂÔËÐÐÃüÁîqvfb&£»QtopiaÖ»ÊÇÒ»¸öÓÃQt/Embedded¿ª·¢µÄ³ÌÐò£¬ÔËÐÐQtopia£¬ÔÚͼÐÎģʽÏÂÔËÐÐÃüÁ


export QTDIR=$QTEDIR,
qpe &£»




ÕâÑùQtopiaµÄ³ÌÐò¾ÍÔËÐÐÔÚQVFBÉÏ£¬¼´QtµÄÐéÄâ·ÂÕæ´°¿Ú¡£

Qt/EmbeddedÊÇÕë¶ÔǶÈëʽLinux¶ø¿ª·¢µÄÒ»ÖÖ¿ª·¢¹¤¾ß£¬Qt·â×°ÁËһЩ³£ÓõÄÀ࣬¶øÇÒÕâЩÀàµÄÃû×Ö¶¼ÒÔQ×Ö¿ªÍ·ÃüÃû£¬ÈçQString¡¢QDialogµÈ¡£ÕâÀïÖ÷Òª½éÉÜÒ»ÏÂÈçºÎÀûÓÃQt DesignerÀ´Éè¼Æ×é¼þ£¬²¢Éú³ÉÏàÓ¦µÄ´úÂë¡£

ÔÚQtÖУ¬°Ñ×é¼þ·ÖΪ¸´ºÏÌ塢ԭʼÌåºÍÅä¼þ¡£¶øÔÚQtÖУ¬×é¼þÊÇÓÉһЩ³éÏóÀà¡¢¸´ÔÓµÄ×é¼þÀà¡¢¹ÜÀí×é¼þ¼¸ºÎÌØÐÔµÄÀàµÈ×é³É¡£

QtÖÐÓÐÈý¸öÖ÷ÒªµÄ»ùÀࣺQObject¡¢QapplicationºÍQWidget¡£

ÔÚQtÖбà³Ì£¬ÀûÓÃSignalºÍSlot½øÐжÔÏóÖ®¼äµÄͨÐÅÊÇQtµÄÖ÷ÒªÌØÕ÷¡£ËüÓëWindowsÖеÄÏûÏ¢»úÖƷdz£ÀàËÆ£¬µ«ÊÇSignalºÍSlot»úÖÆÕæÕýʵÏÖÁËÒ»ÖÖÏûÏ¢µÄ·â×°¡£µ±¶ÔÏóµÄ״̬¸Ä±äʱ£¬·¢³öSignal£¬Í¨ÖªËùÓеÄSlot½ÓÊÜSignal£¬¾¡¹ÜËü²»ÖªµÀÄÄЩº¯ÊýÊÇSlot£¬SlotÒ»¿ªÊ¼Ò²²»ÖªµÀÄÄЩSignal¿ÉÒÔ½ÓÊÕ¡£SignalºÍSlotÖ®¼ä²»ÊÇÒ»Ò»¶ÔÓ¦µÄ¹Øϵ£¬Ò»¸öSignal¿ÉÒÔ·¢¸ø¶à¸öSlot£¬ SlotÒ²¿ÉÒÔ½ÓÊÕ¶à¸öSignal¡£Slot³ýÁË¿ÉÒÔ½ÓÊÕSignalÒÔÍ⣬ÓëÆäËüµÄ³ÉÔ±º¯ÊýûÓÐÇø±ð¡£ÕâÖÖ»úÖƱÈʹÓûص÷º¯ÊýÒªÁé»î£¬µ«ÊÇ»á¼õÂý³ÌÐòµÄÔËÐÐËٶȡ£²»¹ýÔÚÏÖÔÚ¸ßËÙCPUµÄÃæÇ°£¬ÕâÖÖËðʧÊÇÎÞ×ãÇáÖصģ¬¶øÇÒËü»¹Äܱ£Ö¤³ÌÐòµÄ¼òÃ÷ÐÔºÍÁé»îÐÔ£¬·Ç³£±ãÀû¡£

ÔÚQtµÄ×é¼þÖУ¬²»½ö¶¨ÒåÁ˳£ÓõijÉÔ±±äÁ¿ºÍ³ÉÔ±º¯Êý£¬»¹¶¨ÒåÁËËùÓÐÓë¸Ã×é¼þÏà¹ØµÄSignalºÍSlot¡£

Òª½«×é¼þ×éºÏÆðÀ´£¬×î¼òµ¥µÄ·½·¨¾ÍÊÇʹÓÃQt Designer¡£Ê×ÏÈÒªÆô¶¯Qt Designer£¬ÔÚLinuxÃüÁîģʽÏ£¬¼üÈëÒÔÏÂÃüÁî(¼ÙÉèQt°²×°ÔÚ/usr/localÏÂ)£º


cd qt-2.3.2/bin
./designer




ÕâÑù¾Í¿ÉÒÔÆô¶¯Ò»¸öÓëWindowsϵÄDelphiÏàÀàËƵÄÈçͼ1µÄ½çÃæ¡£


È»ºóн¨Ò»¸öQFrame£¬½«×Ô¼ºÐèÒªµÄ×é¼þÖ±½ÓÍÏÀ­µ½Õâ¸öFrameÖУ¬ÏàÐźܶàÈ˶¼ÓйýÕâÑùµÄ¾­Àú£¬´Ë´¦¾Í²»ÔÙÏêϸÃèÊöÁË¡£Íê³ÉÖ®ºó´æÅÌʱ£¬»á½«Õâ¸öеÄ×é¼þ±£´æΪһ¸öÀ©Õ¹ÃûΪ.uiµÄÎļþ¡£¼ÙÉèËù´æµÄÎļþÃûΪtest.ui£¬ÓÃvi test.uiÀ´²é¿´Õâ¸öÎļþ£¬·¢ÏÖÕâÊÇÒ»¸öÓÃxmlÓïÑÔдµÄÒ»¸öÎı¾¡£ÏÂÃæÓÃÕâ¸ötest.uiÉú³ÉÏàÓ¦µÄtest.hºÍtest.cpp¡£Í¬Ñù»¹ÊÇÔÚÕâ¸öĿ¼Ï£¬¿ÉÒÔ¿´µ½Ò»¸öuicµÄ¹¤¾ß£¬Õâ¸öÊÇQtרÃÅÓÃÀ´½«uiÎļþÉú³É.hºÍ.cppÎļþµÄ£¬ÔÚÖÕ¶ËģʽϼüÈëÒÔÏÂÃüÁ


./uic -o test.h test.ui
./uic -o test.h -i test.cpp test.ui





´Ëʱ¾ÍÄÜ¿´µ½Éú³ÉÁËÏàÓ¦test.hºÍtest.cpp£¬ÕâÊÇÒ»¸öÀà¡£µ±È»ÕâÖ»ÊÇһЩ±íÃæµÄ¶«Î÷£¬»¹ÐèÒªÔÚÕâЩ´úÂëÖÐÌí¼ÓÏàÓ¦µÄSignalºÍSlot£¬Íê³ÉËùÐèÒªµÄ²Ù×÷¡£ÖµµÃ×¢ÒâµÄÊÇ£¬ÏàÓ¦°æ±¾Éú³ÉµÄui×îºÃÓÃÏàÓ¦°æ±¾µÄuicÀ´Éú³É´úÂë¡£Èç¹ûÓÃQt 3.1.2µÄDesignerÉú³ÉµÄui£¬ÓÃQt 2.3.2µÄuicÀ´Éú³É´úÂ룬Éú³ÉµÄ´úÂ붼»áÊÇһЩ¿Õº¯Êý¡£

ÔÚÒ»°ãµÄ¿ª·¢¹ý³ÌÖУ¬Ê×ÏÈͨ¹ýÕâ¸öuiÉú³ÉµÄÒ»¸öÀ࣬ÔÚQtÖÐͨ³£½Ð×öBase£¬ÈçÉÏÃæµÄÀý×Ó£¬½Ð×ötestBase£»È»ºóÔÙн¨Ò»¸öÀ࣬À´¼Ì³ÐÕâ¸öBase¡£Í¨³£½Ð×öʵÏÖÀàImpl£¬ÈçtestImpl¡£ÔÚÕâ¸öʵÏÖÀàÀïÃ涨ÒåËùÐèÒªµÄ³ÉÔ±º¯Êý¡¢SignalºÍSlot£¬ÒòΪui¿ÉÄÜÊǾ­³£ÐèÒª¸Ä¶¯µÄ¡£Èç¹ûÕâÑù×ö£¬Ã¿´ÎÖ»ÐèÒªÔÚDesignerÖÐÐÞ¸Äui£¬¶ø²»ÓÃÈ¥Àí»áÕâЩ³ÉÔ±º¯Êý¡¢SignalºÍSlotÁË¡£

±àÒëÒ»¸öQt³ÌÐò±ØÈ»ÐèÒªMakefile£¬ÔÚQtÖÐÌṩÁËÒ»¸öרÃÅÉú³ÉMakefileµÄ¹¤¾ß£¬¾ÍÊÇtmake¡£ÓÃtmakeÐèÒª¸ù¾Ý±àдµÄ³ÌÐòдһ¸ö.proÎļþ¡£.proÎļþ·Ç³£¼òµ¥£¬Óй̶¨µÄ¸ñʽ£¬ÏÂÃæÊÇÒ»¸öÀý×Ó£º


TEMPLATE = app
CONFIG = qtopia warn_on release
MOC_DIR =tmp
OBJECTS_DIR =tmp
HEADERS =fcrs.h\
structs.h \
globalfunc.h \
globalvars.h \
testimpl.h
SOURCES = main.cpp \
globalfunc.cpp\
globalvars.cpp \
testimpl.cpp
INTERFACES = test.ui \
TARGET = fcrs


Éú³ÉÕâ¸ö.proÎļþÖ®ºó£¬ÔÚÖÕ¶ËÖмüÈëÏÂÃæµÄÃüÁ


tmake -o Makefile test.pro


¾Í×Ô¶¯Éú³ÉÁËÒ»¸öMakefile£¬Ê¹ÓÃÕâ¸öMakefile±àÒëËù±àдµÄ³ÌÐò¾Í¿ÉÒÔÁË¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ