Why this ui file doesn't compile
-
Hello,
I'm developping a project using Qt5, and compiling it with CMake. Here's my CMakeLists:
@# Uses 2.8.8 features
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)Configuring project
PROJECT(myProject)
Tell CMake to run moc when necessary
SET(CMAKE_AUTOMOC ON)
As moc files are generated in the binary dir, tell CMake
to always look for includes there:
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
To switch between g++ and clang++
SET(CMAKE_CXX_COMPILER "/usr/bin/clang++")
Commong flags
SET(CMAKE_CXX_FLAGS "-Wall -std=c++11")
Defining to flags regarding to configurations
SET(CMAKE_CXX_FLAGS_DEBUG "-g")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")Widgets finds its own dependencies.
FIND_PACKAGE(Qt5Widgets REQUIRED)
Selecting files to compile
FILE(
GLOB_RECURSE
SOURCE_FILES
src/*.cpp
)FILE(
GLOB_RECURSE
UI_FILES
src/*.ui
)QT5_WRAP_UI(UI_HEADERS ${UI_FILES})
Binary declaration
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCE_FILES} ${UI_HEADERS} ${UI_FILES})
QT5_USE_MODULES(${PROJECT_NAME} Widgets)
@And here is the class where the issues is located:
@#ifndef NEWCLASSGENERATORDIALOG_HPP
#define NEWCLASSGENERATORDIALOG_HPP#include <QtCore/QDate>
#include <QCompleter>
#include <QtWidgets/QDialog>namespace Ui
{
class NewClassGeneratorDialog;
}class NewClassGeneratorDialog : public QDialog
{
Q_OBJECTpublic: explicit NewClassGeneratorDialog(QWidget* parent = nullptr); ~NewClassGeneratorDialog(); private slots: private: Ui::NewClassGeneratorDialog* _ui;
};
#endif // NEWCLASSGENERATORDIALOG_HPP
@The its implementation:
@#include "newClassGeneratorDialog.hpp"
#include "ui_newClassGeneratorDialog.h"NewClassGeneratorDialog::NewClassGeneratorDialog(QWidget* parent) : QDialog(parent), _ui(new Ui::NewClassGeneratorDialog)
{
_ui->setupUi(this);
}NewClassGeneratorDialog::~NewClassGeneratorDialog()
{
delete _ui;
}@And the errors I get:
/home/kevina/Documents/myProject/src/newClassGeneratorDialog.cpp:30:94: error: allocation of incomplete type 'Ui::NewClassGeneratorDialog'
NewClassGeneratorDialog::NewClassGeneratorDialog(QWidget* parent) : QDialog(parent), _ui(new Ui::NewClassGeneratorDialog)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kevina/Documents/myProject/src/newClassGeneratorDialog.hpp:36:11: note: forward declaration of 'Ui::NewClassGeneratorDialog'
class NewClassGeneratorDialog;
^
/home/kevina/Documents/myProject/src/newClassGeneratorDialog.cpp:32:8: error: member access into incomplete type 'Ui::NewClassGeneratorDialog'
_ui->setupUi(this);
^
/home/kevina/Documents/myProject/src/newClassGeneratorDialog.hpp:36:11: note: forward declaration of 'Ui::NewClassGeneratorDialog'
class NewClassGeneratorDialog;
^
/home/kevina/Documents/myProject/src/newClassGeneratorDialog.cpp:37:5: warning: deleting pointer to incomplete type 'Ui::NewClassGeneratorDialog' may cause undefined behaviour [-Wdelete-incomplete]
delete _ui;
^ ~~~
/home/kevina/Documents/myProject/src/newClassGeneratorDialog.hpp:36:11: note: forward declaration of 'Ui::NewClassGeneratorDialog'
class NewClassGeneratorDialog;Thanks in advance ;)
-
Try to edit/repost the information. Your question is truncated.
-
Thanks, I've edited
-
Have you renamed the topmost object in the Designer object inspector to something other than NewClassGeneratorDialog? This object name drives the name of the class generates in the Ui namespace.
-
I just renamed the Dialog in designer and It works.
Thanks so much Chris, I was going mad because of these errors. :p -
sorry for ask, but, I have the same error, I had rename my root object in my dialog and I have the same error... where did you rename the dialog??
best regards
freddy