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
該文件中沒有發生該錯誤。它在'newdialog.h'中。您是否在該文件中包含「inkpuppet.h」? –
我做過了,評論它沒有任何區別。我使用newdialog.h代碼編輯了主帖。 – Vii
替換「InkPuppet * pointerToPuppet;」與「Ui :: InkPuppet * pointerToPuppet;」 – Ashif