Search code examples
c++qtqt-creator

'QMainWindow' file not found


the program works, but I don't like these errors

in mainwindow.h:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow> //'QMainWindow' file not found

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

because of this, errors also appear in the main file

main.cpp:

#include "mainwindow.h" //In included file: 'QMainWindow' file not found

#include <QApplication>

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

the program still works, but I would still like to know the solution to the problem


Solution

  • I have already found answer there: https://stackoverflow.com/a/58737644/18282426

    so, select from above help -> About modules... and disable ClangCodeModel