2013-08-28 32 views
0

QT Creator存在一個非常嚴重的問題。我不能再使用指向其他類的指針,並且autocompletion在我的主類中不起作用。感覺就像有些東西變得腐敗了,但是我的所有代碼都在用現有的幾個指針進行工作,然後所有的代碼都沒有工作並出錯。Qt Creator/C++ - 防止使用指針和自動完成的錯誤

21號線:InkPuppet *pointerToPuppet;錯誤:x:\development\inkpuppet\newdialog.h:21: error: C2143: syntax error : missing ';' before '*'x:\development\inkpuppet\newdialog.h:21: error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int

這裏是我的.pro文件:

QT  += core gui 

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 

TARGET = InkPuppet 
TEMPLATE = app 


SOURCES += main.cpp\ 
     inkpuppet.cpp \ 
    aboutdialog.cpp \ 
    inkspot.cpp \ 
    newdialog.cpp 

HEADERS += inkpuppet.h \ 
    aboutdialog.h \ 
    inkspot.h \ 
    newdialog.h 

FORMS += inkpuppet.ui \ 
    aboutdialog.ui \ 
    newdialog.ui 

OTHER_FILES += \ 
    InkPuppet.pro.user 

RESOURCES += \ 
    resources.qrc 

這是我的默認標題。 inkpuppet.h

#ifndef INKPUPPET_H 
#define INKPUPPET_H 

#include "inkspot.h" 
#include "ui_inkpuppet.h" 

#include <QMainWindow> 
#include <QWidget> 

namespace Ui { 
class InkPuppet; 
} 

class InkPuppet : public QMainWindow 
{ 
    Q_OBJECT 

public: 
    explicit InkPuppet(QWidget *parent = 0); 
    ~InkPuppet(); 

    Ui::InkPuppet *ui; 

private slots: 
    void setMinimum(int value); 
    void setMaximum(int value); 
    void actionNew(); 
    void actionAbout(); 
    void testButton(); 
}; 

#endif // INKPUPPET_H 

newdialog.h

#ifndef NEWDIALOG_H 
#define NEWDIALOG_H 

#include "inkspot.h" 
#include "inkpuppet.h" 
#include "ui_inkpuppet.h" 

#include <QDialog> 

namespace Ui { 
class NewDialog; 
} 

class NewDialog : public QDialog 
{ 
    Q_OBJECT 

public: 
    explicit NewDialog(QWidget *parent = 0); 
    ~NewDialog(); 
    InkPuppet *pointerToPuppet; 

private: 
    Ui::NewDialog *ui; 

private slots: 
    void createNew(); 

}; 

#endif // NEWDIALOG_H 
+1

該文件中沒有發生該錯誤。它在'newdialog.h'中。您是否在該文件中包含「inkpuppet.h」? –

+0

我做過了,評論它沒有任何區別。我使用newdialog.h代碼編輯了主帖。 – Vii

+0

替換「InkPuppet * pointerToPuppet;」與「Ui :: InkPuppet * pointerToPuppet;」 – Ashif

回答

0
  1. 替換 「InkPuppet * pointerToPuppet;」與「Ui :: InkPuppet * pointerToPuppet;」將解決你的編譯問題。
  2. 重新安裝您的SDK可能會解決自動完成問題。 Problem with Qt creator autocomplete code
+0

我有自動完成除一個以外的所有文件。重新安裝不會幫助。而且由於已經說過的原因,Ui :: InkPuppet vs InkPuppet是一個無效的解決方案 – Vii