Qt CMake Semantic Issue
-
Hi
I am having very annoying problems with even fresh project on Qt with CMake. I have no idea what cause such warnings and errors below:mainwindow.cpp:6: error: allocation of incomplete type 'Ui::MainWindow'
mainwindow.h:7: forward declaration of 'Ui::MainWindow'
mainwindow.cpp:8: error: member access into incomplete type 'Ui::MainWindow'
mainwindow.h:7: forward declaration of 'Ui::MainWindow'
mainwindow.cpp:13: warning: deleting pointer to incomplete type 'Ui::MainWindow' may cause undefined behavior
mainwindow.h:7: forward declaration of 'Ui::MainWindow'All of them seems as semantic issue and program could be run.
What is wrong with these errors! -
@MCey said in Qt CMake Semantis Issue:
All of them seems as semantic issue and program could be run
Could be run? How? These are compiler errors!
Do you include "ui_mainwindow.h" in mainwindow.cpp? -
@MCey Can we see your CMakeLists.txt ... this looks like you didn't moc your interface objects.
Without seeing your cmake, here's a couple ideas:
- Make sure you have
set(CMAKE_AUTOMOC ON)
- Use the macro to wrap your UI files:
qt5_wrap_ui(UI_SRC ui/MainWindow.ui ) ... add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC})
Don't just copy that verbatim though. You need to adjust to your cmake, or share it and I'll help you. :)
Edit: I missed this part:
All of them seems as semantic issue and program could be run.
If the program runs then it isn't a cmake issue then it's probably just the parser that the above posts talk about.
- Make sure you have
-
@qtcat Did you build your app?
ui_mainwindow.h is a file which is generated during build. If it is not yet there (because you did not yet build), QtCreator will show this errors/warnings because it does not know what Ui::MainWindow, which comes from that generated file, is.