gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:23:01 25 4
gpt4 key购买 nike

Qt 项目突然停止构建。因此,新的只是基于 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 的空项目。例如:dialog.cpp:

#include "dialog.h"

Dialog::Dialog(QWidget *parent) :
QDialog(parent)
{
}

Dialog::~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 major”操作损坏了。

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

关于c++ - Qt 标准项目和示例停止构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23183949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com