Qt creator не компилирует программу

Только начал программирование в QT creator. Установил прогу на Ubuntu 20.04 через Synaptic. Всё хорошо установилось, запустил creator, создал новый проект, в разделе Kits установил по дефолту Desktop, версию qt поставил пятую, проект сгенерировался, но после генерации выдает ошибки в только что сгенерированном коде (я ничего в нем не менял).

В main.cpp подчеркивает следующие строчки:

  • QApplication a(argc, argv); Ошибка: "variable has incomplete type "QApplication" "
  • MainWindow w; . Ошибка: "unknown type name "MainWindow"

В файле mainwindow.cpp ошибки выдает вот в этих строчках:

  • MainWindow::MainWindow(QWidget *parent)
  • MainWindow::~MainWindow()

Ошибка для двух строчек одинаковая: "use of undeclared indetifier 'MainWindow'".

Также ошибка в файле mainwindow.h в двух строках:

  • class MainWindow : public QMainWindow Ошибка: "expected class name"
  • Q_OBJECT Ошибка: "incomplete result type 'QString' in function defenition".

Вот код файлов: main.cpp

#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{ 
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

mainwindow.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;
}

mainwindow.h:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();

private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

Если кто-то сможет помочь, заранее большое спасибо!


Вот код файла .pro:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.

#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs           deprecated before Qt 6.0.0

SOURCES += \
main.cpp \
mainwindow.cpp

HEADERS += \
mainwindow.h

FORMS += \
mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

Ответы (0 шт):