You need to log in to create posts and topics.

A patch for changing from Qt5 to Qt6

PreviousPage 2 of 2

It worked fine for Qt 6.4.0

Thanks 🙂
So, I will use that version.

 

But, for Qt 6.9.0

It did not find
#include "moc_window.cpp"
and the end of mainwindow.cpp
chatgpt wanted me to remove that row, and all other #include "moc_*.cpp", at the end of files.

After that I got:

I got 20:49:17: Starting /.../SimulIDE-dev/build_XX/executables/SimulIDE_2.0.0-/simulide...
Warning: QLayout: Attempting to add QLayout "" to MainWindow "", which already has a layout (:0, )
Installer::Installer "AVR" "2507102250"
Installer::Installer "Analog" "2507102250"
Installer::Installer "Arduino" "2507102250"
Fatal: ASSERT failure in : "QObject::connect: Unique connection requires the slot to be a pointer to a member function of a QObject subclass.", file /.../Qt/6.9.0/gcc_64/include/QtCore/qobject.h, line 265 (/.../Qt/6.9.0/gcc_64/include/QtCore/qobject.h:265, )
20:49:18: The command "/.../SimulIDE-dev/build_XX/executables/SimulIDE_2.0.0-/simulide" terminated abnormally.

 

Appendix: Some of the conversation with chatgpt

This is a classic Qt upgrade / build-system mismatch issue, and it’s not a real source-code error.
Your intuition (finding the file under build/.../moc/) is exactly right.

What is actually happening

  • moc is running correctly

  • It generates the file here (as it should):

 
 
build_XX/build/moc/moc_window.cpp
  • But your source file is explicitly trying to include it:

 
 
#include "moc_window.cpp" // ← this line is the problem

Since mainwindow.cpp lives in:

 
 
project_root/src/mainwindow.cpp

the compiler looks for:

 
 
project_root/src/moc_window.cpp

which does not exist → error.


Why this happens now (Qt 6 + Creator)

In modern Qt (Qt 6):

  • moc files are:

    • generated automatically

    • compiled automatically

    • NOT meant to be manually included

  • Qt Creator / qmake / CMake handle this via AUTOMOC

Manually including moc_*.cpp is:

  • ❌ unnecessary

  • ❌ fragile

  • ❌ breaks when build directories change


✅ The correct fix (99% of cases)

Remove the manual include

Open mainwindow.cpp and delete the last line:

 
 

#include "moc_window.cpp"

 

 

PreviousPage 2 of 2