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

Linuxƽ̨Qt¿ª·¢Ö®Hello world

·¢²¼Ê±¼ä:2008-07-20 11:04:33À´Ô´:ºìÁª×÷Õß:erfcend
³ö×Ô£ºË®Á÷ÐÄ

Linuxƽ̨ÏÂQtÓ¦ÓóÌÐò¿ª·¢Ö®Hello world£¬Æäʵ¾ÍÊÇѧ×ÅÈçºÎ½¨Á¢¿ª·¢»·¾³¼°ÈçºÎ½«Ô´Îļþ±äΪ¿ÉÕýÈ·Ö´ÐеijÌÐò¡£ÕâÀïÊÇʹÓÃC++½øÐпª·¢µÄÁ÷³Ì¡£

1.°²×°Qt¿ª·¢¿â

ÓжàÖÖ·½·¨¿ÉÒÔ°²×°£¬¿É¸ù¾Ýʵ¼ÊÇé¿ö½øÐÐÑ¡Ôñ¡£ÔÚFedora core 7 (FC7)ÉÏ¿ÉʹÓÃÈí¼þ°ü¹ÜÀíÆ÷À´×Ô¶¯°²×°¡£ÔËÐÐÈí¼þ°ü¹ÜÀíÆ÷£¬Ñ¡Ôñ£º ¿ª·¢ -> KDEÈí¼þ¿ª·¢£¬ÈçÏÂͼ£º

[attach]8641[/attach]

µã»÷¡°¿ÉÑ¡µÄÈí¼þ°ü¡±°´Å¥´ò¿ªÑ¡Ôñ¶Ô»°¿ò£¬ÈçÏÂͼ£º

[attach]8642[/attach]

¹´Ñ¡¡°qt4-devel-***¡±£¬Development files for the Qt toolkit¡£ ***¿ÉÄÜ»áÒòƽ̨¼°°æ±¾¶øÓÐËù²îÒì¡£µã»÷close°´Å¥¹Ø±Õ¶Ô»°¿ò£¬È»ºó½øÐа²×°¡£

2.±à¼­Ô´Îļþ

н¨Ä¿Â¼qthello,²¢½øÈëqthelloĿ¼

mkdir qthello

cd qthello

×¢Ò⣺Qt ³ÌÐòÏîÄ¿²»ÄÜÒÔ "qt"¡¢¡°qt-mt¡±¡¢¡°qte¡± µÈ×÷ΪÆ䶥¼¶Ä¿Â¼Ãû£¬·ñÔò±àÒëʱ»á·¢Éú´íÎó¡£

½¨Á¢Ô´Îļþhello.cpp,²¢ÊäÈëÏÂÁÐÄÚÈÝ£¬È»ºó±£´æ¡£

ÒýÓÃ:
#include
#include


int main( int argc, char **argv )
{
QApplication a( argc, argv );

QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );

a.setMainWidget( &hello );
hello.show();
return a.exec();
}


3.±àÒë

ÒÀ´Î¼üÈëÏÂÁÐÃüÁ

qmake -project #×Ô¶¯Éú³É¹¤³ÌÎļþ qthello.pro
qmake #×Ô¶¯Éú³ÉMakefileÎļþ
make #±àÒ룬Éú³ÉÄ¿±êÎļþhello.oºÍ×îÖյĿÉÖ´ÐгÌÐòqthello

4.ÔËÐÐ

ÔÚµ±Ç°Ä¿Â¼¼üÈëÏÂÁÐÃüÁ

./qthello

ÔËÐнá¹ûÈçÏ£º

[attach]8643[/attach]

×ÜÌåÀ´ËµÊ®·Ö¼òµ¥£¬¹¤³ÌÎļþÒÔ¼°MakefileÎļþµÄ×Ô¶¯Éú³É´ó´ó¼ò»¯ÁË¿ª·¢¹ý³Ì¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 32 ÌõÆÀÂÛ

  1. wujiaodalou911 ÓÚ 2014-01-25 09:37:29·¢±í:

    ÁªÏµÒ»Ï¡£¡£¡£¡£

  2. godman ÓÚ 2014-01-19 18:45:53·¢±í:

    ²»´í ºÜÓаïÖú°¡

  3. herb734044860 ÓÚ 2013-12-28 20:31:55·¢±í:

    :0)1

  4. 1033150 ÓÚ 2013-10-05 11:19:31·¢±í:

    ¸Ï½ô½»²æ±àÒë°É

  5. andrea ÓÚ 2012-12-14 23:24:48·¢±í:

    ºÜÇ¿´ó

  6. sourcehappy ÓÚ 2011-11-22 17:21:29·¢±í:

    ÒÔºó»áѧµÃ

  7. hailiang0208 ÓÚ 2011-11-22 14:24:22·¢±í:

    Õâ¸öÌû×Ó²»´í~

  8. wozdaixxma ÓÚ 2010-09-01 21:15:39·¢±í:

    ÃüÁîûÓÐÕÒµ½ Similar command is: 'make'

  9. wozdaixxma ÓÚ 2010-09-01 21:12:41·¢±í:

    лл·ÖÏí£¡

  10. fsy7901 ÓÚ 2010-02-09 17:41:05·¢±í:

    »¹Ã»Ñ§µ½ÄÇÒ»²½

  11. bolderson ÓÚ 2010-01-26 11:31:14·¢±í:

    ºÇºÇ~ѧϰÖÐ

  12. Alog_W ÓÚ 2009-12-16 17:20:57·¢±í:

    ÏÖÔÚÊÇqt4ÁË,Â¥Ö÷µÄ´úÂëÊÇqt5µÄ
    ÒªÔÚ¿ªÊ¼¼ÓÉÏÕâ¾ä[code]
    #define QT3_SUPPORT
    [/code]

  13. ñÒÏÈÉú ÓÚ 2009-11-06 15:44:30·¢±í:

    Ì«ºÃÁË

  14. beyondhong ÓÚ 2009-10-04 23:17:23·¢±í:

    ÓÐûÓÐ redhat ÃüÁîÐа²×°~~

  15. shenhao0129 ÓÚ 2009-09-11 23:30:26·¢±í:

    Õâ¸öÏÈmarkһϣ¬ÂíÉϾͻáÓõ½ÁË

  16. xiazhouquan ÓÚ 2009-09-11 20:00:30·¢±í:

    лл£¬Ñ§Ï°ÁË

  17. xiazhouquan ÓÚ 2009-09-03 10:21:06·¢±í:

    ҪѧQTµÄ£¬ÊÕÏÂÁË£¬Ð»Ð»Â¥Ö÷

  18. ljbhander ÓÚ 2009-08-18 14:18:01·¢±í:

    qt²»´í£¬Èç¹ûÃâ·Ñ¾Í¸üºÃÁË

  19. AOACGO ÓÚ 2009-08-13 18:52:47·¢±í:

    OH

  20. rockeinstein ÓÚ 2009-08-13 18:23:36·¢±í:

    ¾ÍÊÇÕâ¸öÑù×Ó

  21. rockeinstein ÓÚ 2009-08-13 18:17:58·¢±í:

    hello.cpp: In function int main(int, char**):
    hello.cpp:8: error: class QApplication has no member named setMainWidget
    ÇëÎʸ÷λ´óϺ£¬Õâ¸ö´íÊÇÔõô»ØÊ£¿
    »¹ÓÐÎÒµÄqt designer´ò¿ªÒÔºónew£­>file£¬Ö»Äܽ¨Á¢ÐµĴ°¿Ú£¬²¢Ã»ÓпÉÒÔÑ¡Ôñ½¨Á¢ÐµÄc£«£« procejtµÄÑ¡ÏÇëÎÊÔõô°ì£¿
    ÎÒÊÇÐÂÊÖ£¬¶àÖ¸½Ì£¡

  22. rockeinstein ÓÚ 2009-08-13 18:14:36·¢±í:

    [i=s] ±¾Ìû×îºóÓÉ rockeinstein ÓÚ 2009-8-13 18:17 ±à¼­ [/i]

    hello.cpp: In function int main(int, char**):
    hello.cpp:8: error: class QApplication has no member named setMainWidget
    ÇëÎʸ÷λ´óϺ£¬Õâ¸ö´íÊÇÔõô»ØÊ£¿
    »¹ÓÐÎÒµÄqt designer´ò¿ªÒÔºónew£­>file£¬Ö»Äܽ¨Á¢ÐµĴ°¿Ú£¬²¢Ã»ÓпÉÒÔÑ¡Ôñ½¨Á¢ÐµÄc£«£« procejtµÄÑ¡ÏÇëÎÊÔõô°ì£¿
    ÎÒÊÇÐÂÊÖ£¬¶àÖ¸½Ì£¡

  23. you_me ÓÚ 2009-05-19 11:56:01·¢±í:

    Ö§³Öһϣ¡£¡

  24. 52jimmy ÓÚ 2009-05-18 15:28:34·¢±í:

    ѧϰһÏÂ

  25. haibian ÓÚ 2009-05-02 06:37:22·¢±í:

    ÊÔÒ»ÏÂ
    ---

  26. À¶ÑÕÖª¼º ÓÚ 2009-04-28 20:52:03·¢±í:

    ²»Ì«¶®¹þ£¬²»¹ýÎÒÃÇÏÂÖܾÍҪѧϰQTÁ˹þ

  27. asdfgtanxin ÓÚ 2009-04-10 18:01:29·¢±í:

    ºÃÏñÔÚÄÄ¿´¹ý°¡ ÐÖµÜ ÒÔºó¶à·¢·¢ ´ó¼ÒÒ»ÆðÌÖÂÛ ¶àл´ó¸çµÄ·ÖÏí!

  28. LiuCan007 ÓÚ 2009-04-05 13:34:38·¢±í:

    »¹ÊÇÏÈѧlinuxϵÄC

  29. jerry520 ÓÚ 2009-03-23 13:32:40·¢±í:

    ²»´íÓÖѧϰÁË.

  30. lgwfw ÓÚ 2008-10-22 13:29:19·¢±í:

    Ö§³Ö,QTÊǸöͦ²»´íµÄ¶«Î÷,

  31. shourenyu ÓÚ 2008-10-21 11:16:34·¢±í:

    Ö§³Ö£¡~

  32. lmw303 ÓÚ 2008-08-23 14:35:59·¢±í:

    дµÄ×îÎÒºÜÓаïÖú£¡Ð»Ð»£¡