I want to make it so that when I click on a button from the main menu, a new form opens (not as a dialog, but is replaced with a new form). I created the history.ui form. I also created history.hpp and history.cpp. I’m getting errors in history.cpp.
history.hpp
#ifndef HISTORY_HPP
#define HISTORY_HPP
#include <QDialog>
namespace Ui {
class History;
}
class History : public QDialog
{
Q_OBJECT
public:
explicit History(QWidget *parent = nullptr);
~History();
private:
Ui::History *ui;
};
#endif // HISTORY_HPP
mainwindow.hpp
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QMainWindow>
#include "history.hpp"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_pushButton_3_clicked();
private:
Ui::MainWindow *ui;
History *historyDialog;
};
#endif // MAINWINDOW_HPP
history.cpp
#include "history.hpp"
#include "ui_history.h"
History::History(QWidget *parent) :
QDialog(parent),
ui(new Ui::History)
{
ui->setupUi(this);
}
History::~History()
{
delete ui;
}
enter image description here
I tried rebuilding the project, but I’m still getting errors.
I added all the files to CMakeLists.txt. ChatGPT says that the ui_history.h file is generated automatically.
Ubuntu 24.04 LTS.
QT Creator 13.02.
Puzyryn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.