Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Compilation Errors After Renaming mainwindow to main in Qt Project
Qt 6.11 is out! See what's new in the release blog

Compilation Errors After Renaming mainwindow to main in Qt Project

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 358 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    antleredvixen
    wrote on last edited by
    #1

    I’ve encountered an issue while working on my Qt project, and I could use some guidance. Recently, I renamed mainwindow.cpp and the MainWindow class simply to main and also updated the corresponding header file from ui_mainwindow.h to ui_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::Main class 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.

    1 Reply Last reply
    0
    • A antleredvixen deleted this topic on
    • A antleredvixen restored this topic on
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Your class inside the ui file is still Ui::MainWindow - you either have to use this class name or rename it.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved