Qt标准项目和示例停止构建

Qt standard project and examples stopped building

本文关键字:构建 标准 项目 Qt      更新时间:2023-10-16

Qt项目突然停止建设。因此,as new只是基于QDialog或示例创建了空项目。清洁、重建没有帮助。

关键错误日志:

/Users/dmitrytolstov/Workspace/Qt521/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers/qdialog.h:117: 
error: unknown type name 'QDialog'  
Q_DISABLE_COPY(QDialog)
/Users/dmitrytolstov/Workspace/Qt521/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers/qdialog.h:117: 
error: C++ requires a type specifier for all declarations 
Q_DISABLE_COPY(QDialog)
/Users/dmitrytolstov/Workspace/Qt521/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers/qdialog.h:117: 
error: unknown type name 'QDialog'
/Users/dmitrytolstov/Workspace/CC++/QtStuff/NewDiaproj/dialog.h:10: 
error: unknown class name 'QDialog'; did you mean 'Dialog'?
class Dialog : public QDialog
/Users/dmitrytolstov/Workspace/CC++/QtStuff/NewDiaproj/dialog.h:10: 
error: base class has incomplete type
class Dialog : public QDialog
/Users/dmitrytolstov/Workspace/CC++/QtStuff/NewDiaproj/main.cpp:8: 
error: no member named 'show' in 'Dialog'
w.show();
7 errors generated.
make: *** [main.o] Error 1
18:46:36: Process «/usr/bin/make» exit with code 2.

qdialog.h好像出了什么事。顺便说一句,QMainWindow上的项目运行良好。我什么都没做。尝试重新打开QtCreator,重新启动计算机。我使用Mac OS X和Qt 5.2.1

QtCreator提供的任何示例或基于QDialog的空项目。例如:对话框.cpp:

#include "dialog.h"
Dialog::Dialog(QWidget *parent) :
    QDialog(parent)
{
}
Dialog::~Dialog()
{
}

对话框.h

#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
class Dialog : public QDialog
{
    Q_OBJECT
public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();
};
#endif // DIALOG_H

main.cpp

#include "dialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Dialog w;
    w.show();
    return a.exec();
}

NewDiaproj.pro

#-------------------------------------------------
#
# Project created by QtCreator 2014-04-20T19:31:45
#
#-------------------------------------------------
QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = NewDiaproj
TEMPLATE = app

SOURCES += main.cpp
        dialog.cpp
HEADERS  += dialog.h

基于您的文件在带有Qt 5.2的Archlinux上运行良好的事实,我认为您在Qt安装中的QDialog文件因某些意外或"vis-mail"操作而损坏。

干净地重新安装它,然后它就可以正常工作了。