Eclipse 与 qt 集成

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12670710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:06:59  来源:igfitidea点击:

Eclipse integrate with qt

c++eclipseqt

提问by user1344201

i download qt and eclipse with c++ cdt , i see that qt come with qt ide (qt creator) , to develop qt appliation and that fine , but i want to do this wit eclipse , i mean use c++ code with qt inside eclipse . is there any ? because i am trying to use qt to design my user interface only and using other code from other libraries to do other things .

我用c++ cdt下载qt和eclipse,我看到qt附带qt ide(qt creator),开发qt应用程序很好,但我想用eclipse来做这个,我的意思是在eclipse中使用c++代码和qt。有没有 ?因为我试图仅使用 qt 来设计我的用户界面,并使用其他库中的其他代码来做其他事情。

i try to include header files (usr/include/qt4) , but i still have a problem when i compile the program such us ( can't find qgui.h ) any help the integrate qt with eclipse like netbeans .

我尝试包含头文件 (usr/include/qt4),但是当我编译程序时仍然遇到问题,例如我们(找不到 qgui.h)任何帮助将 qt 与 Eclipse 集成(如 netbeans)。

edit :

编辑 :

here is my output

这是我的输出

13:48:48 **** Incremental Build of configuration Debug for project test ****
Info: Internal Builder is used for build
g++ -o test src/test.o -lQtCore 
src/test.o: In function `main':
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:6: undefined reference to `QApplication::QApplication(int&, char**, int)'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:8: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::exec()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::~QApplication()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:8: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::~QApplication()'
src/test.o: In function `QWidget::resize(int, int)':
/usr/include/qt4/QtGui/qwidget.h:996: undefined reference to `QWidget::resize(QSize const&)'
collect2: error: ld returned 1 exit status

13:48:49 Build Finished (took 1s.609ms)

回答by Andreas Fester

I had to adjust the following settings in "Project Properties => C/C++ General => Paths and Symbols":

我必须在“项目属性 => C/C++ 常规 => 路径和符号”中调整以下设置:

On the "Includes" tab, for the GNU C++ language, add the following include paths:

在“包含”选项卡上,对于 GNU C++ 语言,添加以下包含路径:

  • /usr/include/qt4
  • /usr/include/qt4/QtCore
  • /usr/include/qt4/QtGui
  • /usr/include/qt4
  • /usr/include/qt4/QtCore
  • /usr/include/qt4/QtGui

On the "Symbols" tab, for the GNU C++ language, define the following symbols with a value of "1" (might be different for you, but at least the QT_CC_GNU, QT_CORE_LIB and QT_GUI_LIB are necessary):

在“Symbols”选项卡上,对于 GNU C++ 语言,定义以下值为“1”的符号(可能因您而异,但至少需要 QT_CC_GNU、QT_CORE_LIB 和 QT_GUI_LIB):

  • QT_CC_GNU
  • QT_CORE_LIB
  • QT_GUI_LIB
  • QT_NO_DEBUG
  • QT_SHARED
  • QT_TESTLIB_LIB
  • QT_WEBKIT
  • QT_CC_GNU
  • QT_CORE_LIB
  • QT_GUI_LIB
  • QT_NO_DEBUG
  • QT_SHARED
  • QT_TESTLIB_LIB
  • QT_WEBKIT

With these settings, the source indexer works well. Other than that, Eclipse is simply calling "make" for the build.

使用这些设置,源索引器运行良好。除此之外,Eclipse 只是为构建调用“make”。