Hello,

I am trying to build an application with a mainwindow and two dialogs.
I have successfully created the first dialog. Everything is working just fine.

Now I wanted to create a second dialog. I created it exactly the same way I was creating the first one.

But now there are several error messages popping up.

I dont know what to do or what I did wrong.

I created both dialogs the same way (almost copy and paste)

the .h file looks like that (for the first and second dialog):
Qt Code:
  1. #pragma once
  2. #ifndef SECONDDIALOG_H
  3. #define SECONDDIALOG_H
  4.  
  5. #include "ui_seconddialog.h"
  6. #include <QDialog>
  7. #include <QCloseEvent>
  8.  
  9. namespace Ui
  10. {
  11. class seconddialog;
  12. }
  13.  
  14. class seconddialog: public QDialog
  15. {
  16. Q_OBJECT
  17.  
  18. public:
  19. explicit seconddialog(QWidget* parent = 0);
  20. ~seconddialog();
  21.  
  22.  
  23. public slots:
  24.  
  25. protected:
  26. void closeEvent(QCloseEvent* event);
  27.  
  28. private:
  29. Ui::Dialog ui;
  30.  
  31. private slots:
  32. }
To copy to clipboard, switch view to plain text mode 


the .cpp file

Qt Code:
  1. #include "seconddialog.h"
  2.  
  3.  
  4. Voreinstellungsdialog::Voreinstellungsdialog(QWidget* parent)
  5. : QDialog(parent)
  6. {
  7. ui.setupUi(this);
  8. //more code...
  9.  
  10. }
To copy to clipboard, switch view to plain text mode 

in my mainwindow application I am including both dialogs like this.

mainwindow.h file:

Qt Code:
  1. #include "firstdialog.h"
  2. #include "seconddialog.h"
To copy to clipboard, switch view to plain text mode 


I receive plenty of error messages.

first main error message:

C2011 "Ui_Dialog": "class" Type redefinition
(Source file is compiled main.cpp) QtWidgetsApplication7 C:\Users\lauer\source\repos\QtWidgetsApplication7\ QtWidgetsApplication7\x64\Debug\uic\ui_Messdialog. h 25
other error message:
C2011 "Ui:: Dialog": "class" Type redefinition
(Source file is compiled main.cpp) QtWidgetsApplication7 C:\Users\lauer\source\repos\QtWidgetsApplication7\ QtWidgetsApplication7\x64\Debug\uic\ui_Messdialog. h 25
other error message:
C2027 Use of the undefined type "Ui:: Dialog" QtWidgetsApplication7 C:\Users\lauer\source\repos\QtWidgetsApplication7\ QtWidgetsApplication7\Messdialog.cpp 15