I'm new using Qt c++, I am trying to make a unit test for a GUI, but I can't make a correct instance of my mainwindow class; when I try to build my project I have the following error: Error: undefined reference to
MainWindow::MainWindow(QWidget*)'`
I hope you can help me or guide me!!
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QString>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
setMinimumHeight(MIN_H);
setMinimumWidth(MIN_W);
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
val = QString::number(minimumHeight());
ui->m_Height->setText(val);
ui->m_Width->setText(QString::number(minimumWidth()));
secInstance = new secDialog(this);
secInstance->show();
}
int MainWindow::give_data(){
int data = 1;
return data;
}
tst_gui_test.h
#ifndef TST_GUI_TEST_H
#define TST_GUI_TEST_H
#include <QTest>
#include "mainwindow.h"
class GUI_TEST : public QObject
{
Q_OBJECT
private slots:
void TestSize();
};
#endif // TST_GUI_TEST_H
tst_gui_test.cpp
#include "tst_gui_test.h"
void GUI_TEST::TestSize(){
//MainWindow instance
MainWindow obj;
QVERIFY2(2 == MainWindow::MIN_H, "Not setted");
}
QTEST_MAIN(GUI_TEST)