gpt4 book ai didi

c++ - Eclipse 与 qt 集成

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:05:12 29 4
gpt4 key购买 nike

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

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

编辑:

这是我的输出

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)

最佳答案

我必须在“Project Properties => C/C++ General => Paths and Symbols”中调整以下设置:

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

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

在“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

使用这些设置,源索引器可以正常工作。除此之外,Eclipse 只是为构建调用“make”。

关于c++ - Eclipse 与 qt 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12670710/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com