【问题标题】:Qt standard project and examples stopped buildingQt 标准项目和示例停止构建
【发布时间】:2014-04-20 15:07:05
【问题描述】:

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

ma​​in.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 本身还是 Qt 之上的一些示例项目?如果是后者,能否请您出示您的代码?
  • 请在你使用这个类的地方也显示你的主要功能。
  • 不要发布您的代码作为答案,请编辑您的问题。
  • @ddriver: 在你发表评论之前他已经这样做了:)
  • 请重新安装Qt看看是否能解决问题。您的 Qt 安装似乎已损坏。在此之前,您可以尝试不使用 QtCreator 的命令行,尽管它可能没有任何区别。

标签: c++ qt qt-creator qtgui qdialog


【解决方案1】:

基于您的文件在带有 Qt 5.2 的 Archlinux 上对我来说可以正常工作的事实,我认为您在 Qt 安装中的 QDialog 文件被一些意外或“主要”操作损坏了。

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

【讨论】:

    猜你喜欢
    • 2013-06-22
    • 2015-03-13
    • 1970-01-01
    • 2023-01-18
    • 1970-01-01
    • 1970-01-01
    • 2011-11-04
    • 2021-05-25
    • 2014-12-22
    相关资源
    最近更新 更多