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):
#pragma once
#ifndef SECONDDIALOG_H
#define SECONDDIALOG_H
#include "ui_seconddialog.h"
#include <QDialog>
#include <QCloseEvent>
namespace Ui
{
class seconddialog;
}
{
Q_OBJECT
public:
explicit seconddialog
(QWidget* parent
= 0);
~seconddialog();
public slots:
protected:
private:
Ui::Dialog ui;
private slots:
}
#pragma once
#ifndef SECONDDIALOG_H
#define SECONDDIALOG_H
#include "ui_seconddialog.h"
#include <QDialog>
#include <QCloseEvent>
namespace Ui
{
class seconddialog;
}
class seconddialog: public QDialog
{
Q_OBJECT
public:
explicit seconddialog(QWidget* parent = 0);
~seconddialog();
public slots:
protected:
void closeEvent(QCloseEvent* event);
private:
Ui::Dialog ui;
private slots:
}
To copy to clipboard, switch view to plain text mode
the .cpp file
#include "seconddialog.h"
Voreinstellungsdialog
::Voreinstellungsdialog(QWidget* parent
){
ui.setupUi(this);
//more code...
}
#include "seconddialog.h"
Voreinstellungsdialog::Voreinstellungsdialog(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
//more code...
}
To copy to clipboard, switch view to plain text mode
in my mainwindow application I am including both dialogs like this.
mainwindow.h file:
#include "firstdialog.h"
#include "seconddialog.h"
#include "firstdialog.h"
#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
Bookmarks