Compilation Errors After Renaming mainwindow to main in Qt Project
-
I’ve encountered an issue while working on my Qt project, and I could use some guidance. Recently, I renamed
mainwindow.cppand theMainWindowclass simply tomainand also updated the corresponding header file fromui_mainwindow.htoui_main.h.Initially, everything compiled fine after the change, but now I’m getting persistent compilation errors, even when I roll back to earlier versions that were previously working.Here are some of the errors I’m seeing:
C:\Users\Katie\Code\antleredvixen\nitrous\src\main.cpp:33: error: invalid use of incomplete type 'class Ui::Main' C:/Users/Katie/Code/antleredvixen/nitrous/src/main.cpp: In constructor 'Main::Main(QWidget*)': C:/Users/Katie/Code/antleredvixen/nitrous/src/main.cpp:33:16: error: invalid use of incomplete type 'class Ui::Main' 33 | ui(new Ui::Main), | ^~~~ ... C:/Users/Katie/Code/antleredvixen/nitrous/src/main.cpp:101:15: error: invalid use of incomplete type 'class Ui::Main' 101 | connect(ui->actionOpen, &QAction::triggered, this, [this]() { | ^~It seems like the
Ui::Mainclass isn’t being recognized correctly, but I’m not sure why. I’ve ensured that the correct header files are being included, and I’ve even tried cleaning and rebuilding the project multiple times to no avail.Has anyone encountered a similar issue, or could anyone suggest what might be going wrong here?
Let me know if there are any particular details about my issue I can provide to help diagnose it.
-
A antleredvixen deleted this topic on
-
A antleredvixen restored this topic on
-
Your class inside the ui file is still Ui::MainWindow - you either have to use this class name or rename it.