显示错误的 QT 默认项目
QT default project showing errors
我是qt框架环境的新手,昨晚我应用了一些我在书中找到的例子,一切正常,但是今天当我启动QT creator并尝试再次导入我的项目时,它崩溃了几次。现在,当我创建一个项目并尝试运行它时,它会显示一个错误列表,尽管我没有对其进行任何更改。
尝试更改qglobal.h,但再次出现很多错误,尝试重新配置但没有运气,我还应该提到创建者附带的示例可以工作并运行。
我在 Linux x86-32 位机器上使用 qt-creator 5.4.0 社区和 gcc 4.6
。主窗口.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
主.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
主窗口.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
.pro 文件
#-------------------------------------------------
#
# Project created by QtCreator 2015-01-19T13:57:12
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled1
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
下面是编译输出:
13:57:28: Starting: "/home/user/Qt/5.4/gcc/bin/qmake" /home/user/untitled1/untitled1.pro -r -spec linux-g++ CONFIG+=debug
13:57:28: The process "/home/user/Qt/5.4/gcc/bin/qmake" exited normally.
13:57:28: Starting: "/usr/bin/make"
/home/user/Qt/5.4/gcc/bin/uic ../untitled1/mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../Qt/5.4/gcc/mkspecs/linux-g++ -I../untitled1 -I../Qt/5.4/gcc/include -I../Qt/5.4/gcc/include/QtWidgets -I../Qt/5.4/gcc/include/QtGui -I../Qt/5.4/gcc/include/QtCore -I. -I. -I. -o main.o ../untitled1/main.cpp
In file included from ../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:38:0,
from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:49:44: error: invalid use of incomplete type 'class QWidget'
class Q_WIDGETS_EXPORT QTabWidget : public QWidget
^
In file included from ../Qt/5.4/gcc/include/QtGui/qpaintdevice.h:37:0,
from ../Qt/5.4/gcc/include/QtGui/qpixmap.h:37,
from ../Qt/5.4/gcc/include/QtGui/qicon.h:40,
from ../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtGui/qwindowdefs.h:47:7: error: forward declaration of 'class QWidget'
class QWidget;
^
In file included from ../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:38:0,
from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:157:20: error: 'QShowEvent' has not been declared
void showEvent(QShowEvent *);
^
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:158:22: error: 'QResizeEvent' has not been declared
void resizeEvent(QResizeEvent *);
^
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:159:24: error: 'QKeyEvent' has not been declared
void keyPressEvent(QKeyEvent *);
^
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:160:21: error: 'QPaintEvent' has not been declared
void paintEvent(QPaintEvent *);
^
In file included from ../Qt/5.4/gcc/include/QtGui/qicon.h:37:0,
from ../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h: In member function 'QTabWidgetPrivate* QTabWidget::d_func()':
../Qt/5.4/gcc/include/QtCore/qglobal.h:964:95: error: 'd_ptr' was not declared in this scope
inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); }
^
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:168:5: note: in expansion of macro 'Q_DECLARE_PRIVATE'
Q_DECLARE_PRIVATE(QTabWidget)
^
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h: In member function 'const QTabWidgetPrivate* QTabWidget::d_func() const':
../Qt/5.4/gcc/include/QtCore/qglobal.h:965:113: error: 'd_ptr' was not declared in this scope
inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); }
^
../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:168:5: note: in expansion of macro 'Q_DECLARE_PRIVATE'
Q_DECLARE_PRIVATE(QTabWidget)
^
In file included from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1:0,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h: At global scope:
../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:52:45: error: invalid use of incomplete type 'class QWidget'
class Q_WIDGETS_EXPORT QMainWindow : public QWidget
^
In file included from ../Qt/5.4/gcc/include/QtGui/qpaintdevice.h:37:0,
from ../Qt/5.4/gcc/include/QtGui/qpixmap.h:37,
from ../Qt/5.4/gcc/include/QtGui/qicon.h:40,
from ../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtGui/qwindowdefs.h:47:7: error: forward declaration of 'class QWidget'
class QWidget;
^
In file included from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1:0,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:191:27: error: 'QContextMenuEvent' has not been declared
void contextMenuEvent(QContextMenuEvent *event);
^
In file included from ../Qt/5.4/gcc/include/QtGui/qicon.h:37:0,
from ../Qt/5.4/gcc/include/QtWidgets/qtabwidget.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:38,
from ../Qt/5.4/gcc/include/QtWidgets/QMainWindow:1,
from ../untitled1/mainwindow.h:4,
from ../untitled1/main.cpp:1:
../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h: In member function 'QMainWindowPrivate* QMainWindow::d_func()':
../Qt/5.4/gcc/include/QtCore/qglobal.h:964:95: error: 'd_ptr' was not declared in this scope
inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); }
^
../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:196:5: note: in expansion of macro 'Q_DECLARE_PRIVATE'
Q_DECLARE_PRIVATE(QMainWindow)
^
../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h: In member function 'const QMainWindowPrivate* QMainWindow::d_func() const':
../Qt/5.4/gcc/include/QtCore/qglobal.h:965:113: error: 'd_ptr' was not declared in this scope
inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); }
^
../Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:196:5: note: in expansion of macro 'Q_DECLARE_PRIVATE'
Q_DECLARE_PRIVATE(QMainWindow)
^
../untitled1/main.cpp: In function 'int main(int, char**)':
../untitled1/main.cpp:8:7: error: 'class MainWindow' has no member named 'show'
w.show();
^
make: *** [main.o] Error 1
13:57:30: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: Desktop Qt 5.4.0 GCC 32bit)
When executing step "Make"
13:57:30: Elapsed time: 00:02.
有时在崩溃后,如果您出于某种原因在 Linux 机器上运行,某些配置文件会损坏。尝试重置配置,如果这没有帮助,请尝试重新安装。
相关文章:
- 无法在默认Qt项目中打开源文件"ui_QtGuiApplication.h"
- 在拥有C /CX项目时,是否可以设置calendardatePicker的默认日期
- 默认构造函数 Eclipse 项目中的用户输入
- 如何在QMainWindow的默认布局中排列项目?
- 如何更改Visual Studio 2015中的默认新项目打开C 代码
- 在Visual Studio C 项目中设置默认的附加包含/库路径
- 捕获非默认文件夹上的项目添加事件
- CMFCToolBar 和 CMFCMenuBar 默认不显示动态项目
- 默认Win32项目具有恒定数量的内存泄漏
- 在新的 c++11 项目中,我是否应该默认删除任何操作
- 显示错误的 QT 默认项目
- 如何在Visual Studio中保存默认启动项目
- Eclipse Mars - 为C++项目设置默认设置(默认情况下设置 c++11)
- EclipseCDT-带有现有代码的新Makefile项目-更改全局默认构建目标
- 为什么每当我创建一个新的C++项目时,Eclipse都默认为调试模式
- 默认项目显示在不可编辑的组合框中
- 在Visual Studio 2015中生成默认的Native Activity Android项目时出错
- 修改NetBeans中项目的默认设置
- VS Express 2013 -默认为每个新项目添加.h文件,使其位于相同的目录下
- 如何改变默认#包括在Visual Studio 2013(c++)中,当我创建一个新项目