Pregunta

Qt project suddenly stopped building. So as new just created empty projects based on QDialog or examples. Cleaning, rebuilding not helping.

Log of key errors:

/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.

Seems like something happened with qdialog.h or something. By the way project on QMainWindow works fine. I didn't do anything. Tried to reopen QtCreator, reboot computer. I use Mac OS X and Qt 5.2.1

Any example provided by QtCreator or empty project based on QDialog. For example: 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
¿Fue útil?

Solución

Based on the fact that your files work fine for me on Archlinux with Qt 5.2, I think your QDialog file in the Qt installation got corrupted by some accidental or "vis major" action.

Reinstall it cleanly and then it should just work.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top