自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Qt Eclipse開(kāi)發(fā)環(huán)境的部署 中篇

移動(dòng)開(kāi)發(fā)
本文介紹在不同平臺(tái)上Eclipse開(kāi)發(fā)環(huán)境,本篇是在Windows中進(jìn)行安裝的,請(qǐng)看內(nèi)容

接著Qt Eclipse開(kāi)發(fā)環(huán)境的部署 上篇開(kāi)始繼續(xù)介紹,配置Linux環(huán)境,windows平臺(tái),Eclipse中編寫(xiě)QT程序。

Linux平臺(tái)安裝 (Eclipse ,c++, qt4, fortran)

1, 安裝JDK1.6.bin,并配置環(huán)境變量.

安裝目錄/data/opt/jdk1.6.0_01

修改/etc/profile, 在***添加java的環(huán)境變量:

  1. JAVA_HOME=/data/opt/jdk1.6.0_01  
  2. JAVA_BIN=/data/opt/jdk1.6.0_01/bin  
  3. PATH=$PATH:$JAVA_HOME/bin  
  4. CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar  
  5. export JAVA_HOME JAVA_BIN PATH CLASSPATH 

2, 安裝eclipse

解壓eclipse-cpp-ganymede-SR1-linux-gtk.tar.gz到/data/opt/下

3, 編譯安裝qt

  1. $tar jxvf qt-x11-opensource-src-4.4.3.tar.bz2  
  2. $cd qt-x11-opensource-src-4.4.3  
  3. $./configure -prefix /data/opt/qt-4.4.3  -no-libtiff  
  4. $make && make install  
  5. $vi /data/opt/qt-4.4.3/setqt4 (以后在需要編譯QT程序時(shí),執(zhí)行source setqt4就可以設(shè)置好環(huán)境變量)  
  6. export QTDIR=/data/opt/qt-4.4.3  
  7. export PATH=$QTDIR/bin:$PATH  
  8. export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH 

4, 讓eclipse集成QT

  1. $cd /data/opt/eclipse  
  2. $tar zxvf qt-eclipse-integration-linux.x86-gcc3.3-1.4.0.tar.gz 

5, 讓eclipse集成fortran支持,方法與windows下相同, 使用的文件也相同

6, 安裝apache2,mysql5,php5,svn服務(wù)器

7, 安裝slickedit, matlab7

windows平臺(tái),eclipse中編寫(xiě)QT程序

一:在eclipse中編寫(xiě)一般c++程序

1, file->new ->other ->展開(kāi)C++下的C++ Project ->不選中"Show project types and toolchains only if they are ssupported on the

platform" ->Project Type="Executable"下的"Empty Project", ToolChains="MinGW GCC"

2, 編寫(xiě)文件或?qū)氍F(xiàn)有文件(File -> import ->General 下的 File system)

3, projects -> properties, 展開(kāi)c/c++ Build,settings,在右側(cè)tab頁(yè)中選中"Binary Parsers", 應(yīng)該有兩項(xiàng)是選中的"PE Windows Parser"與"cygwin PE Parser" (默認(rèn)生成的未選中"cygwin PE Parser"項(xiàng),造成在下一步生成運(yùn)行配置時(shí)無(wú)法自動(dòng)找到exe)

4, 生成運(yùn)行配置. "run" -> "run configurations..."  , 雙擊"C++ local application"在下面生成一個(gè)新的配置"new_configuration", 在右側(cè)點(diǎn)"project"后的"browse..."選擇剛才新建的項(xiàng)目名, 點(diǎn)"c/c++ application"后"search project..." 找到可執(zhí)行文件, 然后就可以點(diǎn)擊"run"運(yùn)行了.

二:導(dǎo)入有pro文件的qt項(xiàng)目到eclipse中

file -> import -> 選擇qt下qt project ->選擇一個(gè)QT的項(xiàng)目文件(xx.pro),就生成一個(gè)與原project同名的eclipse項(xiàng)目.但"生成運(yùn)行配置"還是要做的,之后就可以編譯與運(yùn)行了.
 

三,一般C++ Project如何增加對(duì)QT的支持

file, new, c++ project => Project type選擇"Executable"下的"Empty Project",不選中"Show project types and toolchains only if they are ssupported on the platform",然后在右側(cè)的"Tool Chains"選擇"MinGW GCC",然后點(diǎn)擊"next", 在彈出的對(duì)話框中點(diǎn)擊"Advanced settings",展開(kāi)"c/c++ build" -> "settings",在右側(cè)展開(kāi)"gcc c++ compiler","Directories", 右側(cè)"include pathes" , 瀏覽添加d:\Qt\4.4.3\include;

展開(kāi)"GCC C++ Linker","Libraries",在Libraries(-l)中添加三次,分別添加QtCored4, QtGuid4, qtmaind;

在"Library search path"添加d:\qt\4.4.3\lib;

新建Source File, 輸入代碼,就可以正常編譯了.

測(cè)試代碼:

 

  1. #include   
  2. #include   
  3. int main(int argc, char *argv[])   
  4. {   
  5.     QApplication app(argc, argv);   
  6.     QPushButton hello("Hello world!");   
  7.     hello.resize(100, 30);   
  8.     hello.show();   
  9.     return app.exec();   
  10. }  

測(cè)試代碼二:

  1. /*   
  2. * myclass.h   
  3. *   
  4. *  Created on: 2008-10-14   
  5. *      Author: lj   
  6. */   
  7. #ifndef MYCLASS_H_   
  8. #define MYCLASS_H_   
  9. #include   
  10. #include   
  11. class MyClass : public QObject   
  12. {   
  13. public:   
  14. MyClass( const QString& text, QObject *parent = 0 );   
  15. const QString& text() ;   
  16. void setText( const QString& text );   
  17. int getLengthOfText() ;   
  18. private:   
  19. QString m_text;   
  20. };   
  21. #endif /* MYCLASS_H_ */   
  22.  
  23. /*   
  24. * myclass.cpp   
  25. *   
  26. *  Created on: 2008-10-14   
  27. *      Author: lj   
  28. */   
  29. #include "myclass.h"     
  30. MyClass::MyClass( const QString &text, QObject *parent ) : QObject( parent )   
  31. {   
  32.   m_text = text;   
  33. }   
  34. const QString &MyClass::text() { return m_text; }   
  35. void MyClass::setText( const QString &text ) { m_text = text; }   
  36. int MyClass::getLengthOfText() { return m_text.size(); }   
  37. /*   
  38. * main.cpp   
  39. *   
  40. *  Created on: 2008-10-14   
  41. *      Author: lj   
  42. */   
  43. #include "myclass.h"     
  44. #include      
  45. int main( int argc, char **argv )   
  46. {   
  47.   QObject parent;   
  48.   MyClass *a, *b, *c;   
  49.   a = new MyClass( "foo", &parent );   
  50.   b = new MyClass( "ba-a-ar", &parent );   
  51.   c = new MyClass( "baz", &parent );   
  52.   qDebug() << a->text() << " (" << a->getLengthOfText() << ")";   
  53.   a->setText( b->text() );   
  54.   qDebug() << a->text() << " (" << a->getLengthOfText() << ")";   
  55.   return a->getLengthOfText() - c->getLengthOfText();   
  56. }  

至此,在windows平臺(tái)上編譯運(yùn)行QT4程序的設(shè)置已經(jīng)完成,后面就是實(shí)際的編程了.

小結(jié):Qt Eclipse開(kāi)發(fā)環(huán)境的部署 中篇的內(nèi)容講解完了,希望對(duì)你有幫助,那么請(qǐng)看 Qt Eclipse開(kāi)發(fā)環(huán)境的部署 下篇。

 

責(zé)任編輯:zhaolei 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-06-17 16:47:12

Qt Eclipse Windows

2011-06-17 17:16:01

Qt Eclipse Linux

2009-06-08 20:19:07

EclipseMinGWQt

2011-06-15 15:01:32

2013-07-29 14:23:55

Eclipse開(kāi)發(fā)環(huán)境Eclipse開(kāi)發(fā)環(huán)境

2011-06-23 18:04:42

Qt Embedded

2012-06-05 01:23:14

Ubuntueclipse

2011-09-13 17:15:58

Eclipse And

2015-10-16 13:30:59

EclipsePython開(kāi)發(fā)環(huán)境

2010-06-12 16:29:00

BlackBerry開(kāi)

2011-06-30 10:22:48

QT Graphics View

2011-06-16 17:45:46

Qt Wince

2011-06-13 15:33:24

Qt Qt 4.5

2011-06-08 17:32:18

QT VS2008 開(kāi)發(fā)環(huán)境

2009-07-14 13:14:13

2009-06-10 16:30:05

基于Eclipse的PWindows

2010-08-19 10:02:25

AndroidEclipseUbuntu

2011-06-28 10:20:19

Ubuntu Qt Designer

2011-06-28 15:09:38

Qt Maemo

2011-06-13 13:06:48

Gtk Qt
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)