Windows-Qt-EclipseCDT 环境问题集

来源:互联网 发布:港澳台网络电视机顶盒 编辑:程序博客网 时间:2024/05/04 05:52

转自:http://4137613.blog.51cto.com/4127613/743342

Windows-Qt-EclipseCDT 环境问题集



问题1:Qt的makefile 文件损坏。需要手动重新生成。
解决方法:从命令提示行进入Qt的工程目录,使用qmake -project 和qmake生成Makefile文件(我们将要使用其生成的Makefile.Release文件)。注意,重新生成的文件头部可能不同,需要自己添加库,如:
TARGET = Test
QT += core \
   gui \
   xml


问题2:给eclipse设置Qt Versions时,找不到qmake等文件。
解决方法:新版QtSDK的qmake等文件路径非常古怪,qmake等文件在Desktop\Qt路径下。

问题3:无法编译,控制台提示为:
Makefile:66: *** multiple target patterns. Stop.
解决方法:一定要用Qt的eclipse插件目录中的,start.bat启动eclipse,像平常那样直接启动eclipse.exe是没用的。

问题4:无法编译,控制台提示为:
(Cannot run program "make": Launching failed)
解决方法:在mingw/bin中复制一份mingw32-make.exe,改名为make.exe。

问题5:无法启动调试,控制台提示为:
[New thread 5020.0x100c]
You can't do that without a process to debug.
解决方法:modify D:/Qt/qt-eclipse-integration-win32-1.6.1/start.bat as: 

@echo off 
rem 
rem This file is generated by the installer 
rem

echo Setting up environment... 
echo -- Using MinGW in: D:/Qt/4.6.2_for_mingw/bin;D:/Qt/mingw/bin;

set PATH=D:/Qt/4.6.2_for_mingw/bin;D:/Qt/mingw/bin;D:/Qt/4.6.2_for_mingw/lib 
set PATH=%PATH%;%SystemRoot%/System32

echo Starting eclipse... 
cd D:/Qt/eclipse-cpp-galileo-SR2-win32/eclipse
start eclipse.exe -clean
exit
 
now I can debug qt program in eclipse.

问题6:method setupUi could not be resolved
eclipse不能识别ui.*,报错。例如:

Hi
I'm working on Eclipse IDE with qt4 plugin. Everythings work fine, all programs are compiling well, with no errors from compilator.
But I have one very annoying error which comes from Eclipse IDE.
syntax checker underlines ui.setupUi(this); with message: Method setupUi could not be resolved. This error have no matter for my application, and its work fine. but i cant stand to see the red underline in my project. I think that the problem is with my eclipse configuration.

here is the class with that error:

Qt Code:
Switch view
 
 
  1. #include "qtmyapp.h"
  2.  
  3. QTMyApp::QTMyApp(QWidget *parent)
  4. : QWidget(parent)
  5. {
  6. ui.setupUi(this); // <-- here is the error
  7. }
  8.  
  9. QTMyApp::~QTMyApp()
  10. {
  11.  
  12. }
  13.  
  14. #include <QtGui/QWidget>
  15. #include "ui_qtmyapp.h"
  16.  
  17. class QTMyApp : public QWidget
  18. {
  19. Q_OBJECT
  20.  
  21. public:
  22. QTMyApp(QWidget *parent = 0);
  23. ~QTMyApp();
  24.  
  25. private:
  26. Ui::QTMyAppClass ui; //<-- and here
  27. };
解决方法:

Re: Eclipse error - method setupUi could not be resolved

Hi,

I had exactly the same error. I found this solution:

1 - Go to your project's properties [alt+enter];
2 - Go to left menu option C/C++ general->Indexer;
3 - Check all check boxes (just like the picture).



问题7:如何使用release编译
解决方法:project properties->C/C++ Make Project->Make Builder->Build(Incremetal Build) 属性 修改为release


问题8:调试时会在进入main之前,会停住。提示为:
No source available for "main() at 0x401729" 
解决方法:Debug Configurations->Debugger->不要选中Stop on startup at main。非常莫名其妙的玩意

问题9:如何安装Windows-Qt-EclipseCDT环境
解决方案:现在不需要单独下MinGW了,也不需要自己编译Qt才能调试了,只需要安装QtSDK,EclipseCDT和qt-eclipse-integration插件就行了,非常简单,可以参考http://blog.csdn.net/delores/article/details/5469731

问题10:如何使用头文件索引文件管理头文件
这是一个经典技巧,除了微软的筛选器(虚拟文件夹)以外,大部分IDE还是通过物理文件夹组织头文件,所以如何组织头文件是非常费力的。一般我们都是用一个索引头文件来表示,例如
src/xxx/yyy/zzz/A.h
src/xxx/yyy/zzz/A.cpp
src/aaa/bbb/ccc/B.cpp
如何给B.cpp导入A.h,如果使用相对路径,管理大量头文件非常复杂
解决方案:我们可以写一个索引头文件
inc/A.h
在其内部 #include "../src/xxx/yyy/zzz/A.h"
在B.cpp中可直接导入
#include "A.h"
然后只需要在*.pro中使用
INCLUDEPATH += inc
另外,需要在project->Proeperties->C/C++ Include Paths and Symbols
点Add External Include Path...
导入inc的目录,这样才能使用自动完成功能

问题11:为何配置了图标路径,结果不显示
解决方法:qrc中使用的是前缀+相对路径的描述方式,例如:
    <qresource prefix="/">
        <file>images/01042.png</file>
他在项目中的相对路径就是images/01042.png,而他最终路径则一般是前缀+相对路径的合成路径,所以为了保持一致,一般我们把前缀设置为/

问题12:STL自动完成不能提示,或STL代码不能编译
解决方法:
1.windows->preferences->Build->Environment->添加两个变量

CPLUS_INCLUDE_PATH
D:\windows7\soft\QtSDK\mingw\lib\gcc\mingw32\4.4.0\include\c++
C_INCLUDE_PATH
D:\windows7\soft\QtSDK\mingw\include

2.project->Proeperties->C/C++ Include Paths and Symbols
点Add External Include Path...
添加如下路径
D:\windows7\soft\QtSDK\mingw\include
D:\windows7\soft\QtSDK\mingw\lib\gcc\mingw32\4.4.0\include
D:\windows7\soft\QtSDK\mingw\lib\gcc\mingw32\4.4.0\include\c++
D:\windows7\soft\QtSDK\mingw\lib\gcc\mingw32\4.4.0\include\c++\bits
D:\windows7\soft\QtSDK\mingw\lib\gcc\mingw32\4.4.0\include\c++\mingw32
D:\windows7\soft\QtSDK\mingw\lib\gcc\mingw32\4.4.0\include\c++\backward

3.右键点项目,选择index->rebuild

问题13:程序总是停在ntdll的某个函数,而未进入main函数
比如:7 ntdll!LdrAddRefDll()  0x7c92ebab    
解决方法:打开程序的Debug Configurations,修改Debugger Options:不要选"Load shared library symbols automatically"。

问题14:Qt的帮助文档在哪里
解决方法:Desktop\Qt\4.7.4\mingw\bin\assistant.exe

问题15:Qt帮助文档为什么打开是空的
解决方法:你安装目录下有没有这个文件 qt.qch 若有 这样操作 在edit->preferences->documentation 添加那个文件 再检索
 
问题16:调试时,打断点无法命中
提示为:Breakpoint attribute problem: installation failed
暂未解决

问题17:release编译的exe,无法在没有安装Qt的windwos环境中运行
解决方法:将运行需要的dll和exe一起打包即可,例如:
libgcc_s_dw2-1.dll
mingwm10.dll
QtCore4.dll
QtGui4.dll
QtXml4.dll

问题18:如何开启编译器预定义宏
解决方法:项目属性 - C/C++ General - Paths and Symbols 其中Symbols就是宏定义,Libraries就是静态库,直接写名字。再把自己的库路径写到LibraryPaths里就可以了。

问题19:QtDesigner在编辑QWidget无法创建QToolBar的问题
解决方法:写把xml修改为QMainWindow,添加若干QToolBar,然后修改回QWidget,就可以使用了。

 

 

本文出自 “老G的小屋” 博客,请务必保留此出处http://4137613.blog.51cto.com/4127613/743342

 

原创粉丝点击