`no member named ‘setupUi’`
-
Hi, I'm new to Qt. I couldn't find anything about this. I'm trying to setup QtDesigner and use a .ui file with C++ and CMAKE outside of QtCreator. I'm following this guide exactly but I'm still running into this problem. They want me to use forward declaration of MainWindow in Ui namespace but define it outside of the namespace, i.e.
namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { ...
But this gives me
error: invalid use of incomplete type ‘class Ui::MainWindow’
. When I useUi::
for the class and member definitions I get this error. In fact, in both cases I get this error, with or withoutUi::
‘class Ui::MainWindow’ has no member named ‘setupUi’ 8 | ui->setupUi(this); | ^~~~~~~
Is this a linking problem or Qt problem? I can provide more info or my CMakeLists if necessary but it's almost exactly what's shown in that guide. Thanks.
-
This is a source code problem. Your cpp file should #include the source generated by
uic
from your filename.ui file; usually a file called "ui_filename.h". This is what is shown in the mainwindow.cpp from your example.