linuxϵͳ¼°±à³Ì»ù´¡¿Îºó´ð°¸ ÏÂÔØ±¾ÎÄ

gtk_box_pack_start(GTK_BOX(vbox),hbox4,TRUE,TRUE,5); button=gtk_button_new_with_label(\

gtk_box_pack_start(GTK_BOX(hbox4),button,TRUE,TRUE,5);

g_signal_connect(G_OBJECT(button),\ button=gtk_button_new_with_label(\

gtk_box_pack_start(GTK_BOX(hbox4),button,TRUE,TRUE,5);

g_signal_connect(G_OBJECT(button),\ button=gtk_button_new_with_label(\

gtk_box_pack_start(GTK_BOX(hbox4),button,TRUE,TRUE,5);

g_signal_connect(G_OBJECT(button),\ button=gtk_button_new_with_label(\

gtk_box_pack_start(GTK_BOX(hbox4),button,TRUE,TRUE,5);

g_signal_connect(G_OBJECT(button),\

gtk_widget_show_all(window); gtk_main(); return FALSE; }

ÔËÐнá¹ûͼ£º

µÚ9Õ ϰÌâ´ð°¸

1£® Qt×Ô´øÍ¼Ðοª·¢¹¤¾ßÓÉÄÄЩ¹¤¾ß×é³É£¿

´ð£ºQt Designer¿ÉÊÓ»¯µØÉè¼ÆÊÓ´°£¬QmakeÓɼòµ¥µÄÓîÆ½Ì¨Î޹صÄÏîÄ¿ÎļþÉú³ÉMakefile£¬QtÖúÊÖ¿ìËٵط¢ÏÖÄãËùÐèÒªµÄ°ïÖú£¬qembedת»»Êý¾Ý£¬±ÈÈç°ÑͼƬת»¹ÎªC++´úÂ룬qvfbÔÚ×ÀÃæÉÏÔËÐкͲâÊÔǶÈëʽӦÓóÌÐò£¬makeqpfΪǶÈëʽÉ豸ÌṩԤÏÈ×öºÃµÄ×ÖÌ壬mocÔª¶ÔÏó±àÒëÆ÷£¬uicÓû§½çÃæ±àÒëÆ÷£¬qtconfigÒ»¸ö»ùÓÚUnixµÄQtÅäÖù¤¾ß£¬ÕâÀïÊÇÔÚÏß°ïÖú¡£

2£® ÔÚÎÞµÚÈý·½¿ª·¢¹¤¾ßµÄÇé¿öÏ£¬ÈçºÎ±àÒëQT³ÌÐò£¿

´ð£ºÏÈÓÃvi±à¼­Ô´´úÂë±£´æ£¬ÔÚ±àÒë³ÌÐò֮ǰ£¬ÒªÊ×ÏÈÉú³ÉËüµÄMakefileÎļþ¡£´ò¿ªÒ»¸öÖÕ¶Ë£¬È»ºóÇл»ÖÁ

±£´æÓÐÏîÄ¿µÄλÖã¬Ê¹ÓÃÒÔÏÂÃüÁîÀ´Éú³ÉMakefileÎļþ£º

[root@localhost~]#qmake -o Makefile hellopro

ÏÖÔÚ£¬¾Í¿ÉÒÔÔËÐÐmakeÀ´±àÒë³ÌÐòÁË£¬¸ù¾ÝϵͳµÄÐÔÄÜ£¬Õâ¸ö²½ÖèÐèÒª»¨·ÑÒ»µãʱ¼ä¡£µ±±àÒ빤×÷Íê³Éºó£¬[root@localhost~]#qmake -o Makefile hellopro [root@localhost~]#make [root@localhost~]#.hello

3£® Qt±à³ÌµÄºËÐÄ»úÖÆÊÇʲô£¿ÓëWindows±à³ÌÓÐʲôÒìͬµã£¿

´ð£ºÐźţ¨signals£©ºÍ²Û£¨slots£©»úÖÆÊÇQtµÄºËÐÄ»úÖÆ£¬ÐźźͲÛÊÇÒ»Öָ߼¶½Ó¿Ú£¬Ó¦ÓÃÓÚ¶ÔÏóÖ®¼äµÄͨÐÅ£¬ËüÊÇQtµÄºËÐÄÌØÐÔ£¬Ò²ÊÇQtÇø±ðÓÚÆäËü¹¤¾ß°üµÄÖØÒªµØ·½¡£ÐźźͲÛÊÇQt×ÔÐж¨ÒåµÄÒ»ÖÖͨÐÅ»úÖÆ£¬Ëü¶ÀÁ¢ÓÚ±ê×¼µÄC/C++ÓïÑÔ£¬Òò´ËÒªÕýÈ·µÄ´¦ÀíÐźźͲۣ¬±ØÐë½èÖúÒ»¸ö³ÆÎªmoc£¨Meta Object Compiler£©µÄQt¹¤¾ß£¬¸Ã¹¤¾ßÊÇÒ»¸ö C++ Ô¤´¦Àí³ÌÐò£¬ËüΪ¸ß²ã´ÎµÄʼþ´¦Àí×Ô¶¯Éú³ÉËùÐèÒªµÄ¸½¼Ó´úÂë¡£ËüÓëWindowsʼþÇý¶¯»úÖÆÏàÀàËÆÓÖ²»ÍêÈ«Ïàͬ¡£

4£® Eclipse+Qt¿ª·¢»·¾³µÄÅäÖùý³ÌÊÇʲô£¿ÊԴÆðEclipse+Qt¿ª·¢Æ½Ì¨¡£

´ð£ºÏȰ²×°Eclips£¬È»ºóµ½Õâ¸öÍøÕ¾http://qt.nokia.com/developer/eclipse-integrationÉÏÈ¥ÏÂÔØQt pluginѹËõ°ü£¬½âѹµÃµ½Á½¸ö×ÓÎļþ¼Ð·Ö±ðΪpluginsºÍfeatures£¬½«ÕâÁ½¸öÎļþ¼Ð¸²¸Ç/usr/lib/eclipse/Îļþ¼ÐϵÄͬÃûÎļþ¼Ð£¬´ò¿ªEclipse , ÔÚ\´°¿Ú->Ê×Ñ¡Ïî->qt\ÀïÅäÖÃÈçÏÂÐÅÏ¢:

Name : Qt

Bin Path : /usr/lib/qt4/bin Include Path : /usr/include/ 5£® ±ê×¼ÊäÈë¿òÄÜΪÄÄЩÊý¾ÝÀàÐ͵ÄÌṩÊäÈ룿

´ð£º±ê×¼ÊäÈë¿òÄÜÌṩ¶àÖÖÊý¾ÝÀàÐ͵ÄÊäÈ룬±ÈÈç×Ö·û´®£¬IntÀàÐÍ£¬DoubleÀàÐÍ»òÊÇÏÂÀ­Áбí¿òµÄÌõÄ¿¡£ 6£® »ùÓÚQT±àдһ¸ö¼ÆËãÆ÷³ÌÐò¡£ ´ð£ºÔ´´úÂë½ö¹©²Î¿¼£º main.cpp£º #include \#include int main(int argc, char **argv) {

int result = 0;

QApplication app(argc, argv); CWidget *main = new CWidget(); main->setCaption(\

app.connect(&app,SIGNAL(lastWindowClosed()),SLOT(quit())); main->show(); result = app.exec(); return result; }

cwidget.h£º

#ifndef CWIDGET_H #define CWIDGET_H #include

ÊäÈë./helloÀ´ÔËÐгÌÐò¡£ÒÔÉÏÕû¸öµÄ±àÒëÔËÐÐÃüÁîÐйý³Ì×ܽáÈçÏ£º

#include #include #include #include #include #include class CWidget : public QWidget {

Q_OBJECT public:

CWidget(QWidget *parent=0, char *name=0); ~CWidget(); private:

QLineEdit *edit; QPushButton *button[16]; QVBoxLayout *mainLayout; QHBoxLayout *topLayout; QGridLayout *bottomLayout; int firstNum; int secondNum; int oper; protected slots: void setValue(); void setOper(); void calculate(); void clear(); protected:

virtual bool event(QEvent *e); private: void initialize(); void createForm(); void onClicked(int key); }; #endif

cwidget.cpp£º #include \#define KEY_CLR \#define KEY_ADD \#define KEY_SUB \#define KEY_MUL \#define KEY_DIV \

#define KEY_EQ \#define KEY_0 \#define KEY_1 \#define KEY_2 \#define KEY_3 \#define KEY_4 \#define KEY_5 \#define KEY_6 \#define KEY_7 \#define KEY_8 \#define KEY_9 \#define BUTTONWIDTH 30 #define BUTTONHEIGHT 30 static char *buttontext[] = {

KEY_1,KEY_2,KEY_3,KEY_4, KEY_5,KEY_6,KEY_7,KEY_8,

KEY_9,KEY_ADD,KEY_SUB,KEY_MUL, KEY_DIV,KEY_EQ,KEY_CLR,KEY_0 };

CWidget::CWidget(QWidget *parent, char *name) {

initialize(); createForm(); }

CWidget::~CWidget() {

delete edit; delete *button; delete mainLayout; delete topLayout; delete bottomLayout; }

void CWidget::calculate() {

switch(oper) {

case Qt::Key_Plus:

firstNum += secondNum;break; case Qt::Key_Minus: