Opening a new window form crashes.
-
Hi everyone,
I am having a problem with opening a new form by clicking a button. Whenever I push on the button which will open a new form, the program crashes and gives me the error 1073741819. I searched the web and found out that it's a access violation. I defined a pointer mProgram in private form of mainwindow.h and tried to show that pointer in void pushbutton. I don't know what i am doing wrong..
This is my mainwindow.cpp
@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "mainprogram.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ui->setupUi(this);
MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::on_pushButton_clicked()
{
mProgram->show();}
@This is my mainprogram.cpp
@
#include "mainprogram.h"
#include "ui_mainprogram.h"
#include "QApplication"mainProgram::mainProgram(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::mainProgram)
{
ui->setupUi(this);
}mainProgram::~mainProgram()
{
delete ui;
}
@This is my mainwindow.h
@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include "mainprogram.h"namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void on_MainWindow_iconSizeChanged(const QSize &iconSize);private slots:
void on_pushButton_clicked();
private:
Ui::MainWindow *ui;
mainProgram *mProgram;
};#endif // MAINWINDOW_H
@and this is my mainprogram.h
@
#ifndef MAINPROGRAM_H
#define MAINPROGRAM_H#include <QMainWindow>
#include <QApplication>namespace Ui {
class mainProgram;
}class mainProgram : public QMainWindow
{
Q_OBJECTpublic:
explicit mainProgram(QWidget *parent = 0);
~mainProgram();private:
Ui::mainProgram *ui;};
#endif // MAINPROGRAM_H
@
I am just trying to open a new form named "mainprogram" from mainwindow. I am new QT and trying to learn some basics and would appreciate any help.. Thank you
-
Thank you for the replies, but I tired them before and got this error, and honestly couldn't find any piece of solution to this. any suggestions?
error LNK2019: unresolved external symbol "public: __thiscall mainProgram::mainProgram(class QWidget *)" (??0mainProgram@@QAE@PAVQWidget@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)
I