Windows-Qt-EclipseCDT 環境問題集

pamxy發表於2013-06-15

轉自: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:
 
 
  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
C_INCLUDE_PATH

2.project->Proeperties->C/C++ Include Paths and Symbols
點Add External Include Path...
新增如下路徑

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

 

相關文章